Skip to content

Releases: tgockel/fmtbuf

Release list

v0.2.0

Choose a tag to compare

@tgockel tgockel released this 29 Apr 21:47
v0.2.0
83bbbe6

Added

  • WriteBuf::finish() and related functions now return validated
    &strs instead of &[u8]s you have to validate yourself. This makes
    this library useful for the simple case of writing to a
    fixed-size/preallocated buffer.
  • WriteBuf::capacity() returning the size of the target buffer.
  • WriteBuf::remaining() returning the number of bytes still available
    for write_str operations (truncation-aware; saturates on
    reserve > capacity - position).
  • WriteBuf::clear() resetting position and the truncated flag for
    buffer reuse. The configured reserve is preserved.
  • Truncated<'_> error type, returned by the WriteBuf::finish*
    family. Carries the portion of the output that was successfully
    written so callers don't have to track it separately.
  • Truncated::written() and Truncated::written_len() -- inherent
    accessors that mirror the methods on TruncatedResultExt so the
    same vocabulary works whether you hold the Truncated directly or a
    Result<&str, Truncated<'_>>.
  • WriteBuf::written() returns the written portion as a &str
    (companion to the existing written_bytes() accessor).
  • fmt::Debug impl on WriteBuf for diagnostic logging. Shows
    position, capacity, reserve, the truncated flag, and the
    validly-written &str; deliberately omits the raw target bytes, as
    they may be uninitialized.

Changed

  • Breaking: WriteBuf::finish, WriteBuf::finish_with, and
    WriteBuf::finish_with_or now return Result<&str, Truncated<'_>>
    instead of Result<usize, usize>. The new shape gives callers the
    validated string slice directly without a separate from_utf8 step
    on the underlying buffer.
  • Breaking: finish_with and finish_with_or now require
    impl AsRef<str> for the suffix arguments (previously
    impl AsRef<[u8]>). This keeps the UTF-8 invariant at the type level
    rather than relying on a runtime check.
  • Breaking: Minimum supported Rust version raised to 1.81 (for
    stable core::error::Error); edition is now 2021.

Removed

  • Breaking: rfind_utf8_end is no longer re-exported from the
    crate root. It remains as a crate-internal helper.