Releases: tgockel/fmtbuf
Releases · tgockel/fmtbuf
Release list
v0.2.0
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
forwrite_stroperations (truncation-aware; saturates on
reserve > capacity - position).WriteBuf::clear()resettingpositionand thetruncatedflag for
buffer reuse. The configuredreserveis preserved.Truncated<'_>error type, returned by theWriteBuf::finish*
family. Carries the portion of the output that was successfully
written so callers don't have to track it separately.Truncated::written()andTruncated::written_len()-- inherent
accessors that mirror the methods onTruncatedResultExtso the
same vocabulary works whether you hold theTruncateddirectly or a
Result<&str, Truncated<'_>>.WriteBuf::written()returns the written portion as a&str
(companion to the existingwritten_bytes()accessor).fmt::Debugimpl onWriteBuffor 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_ornow returnResult<&str, Truncated<'_>>
instead ofResult<usize, usize>. The new shape gives callers the
validated string slice directly without a separatefrom_utf8step
on the underlying buffer. - Breaking:
finish_withandfinish_with_ornow 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
stablecore::error::Error); edition is now 2021.
Removed
- Breaking:
rfind_utf8_endis no longer re-exported from the
crate root. It remains as a crate-internal helper.