pub struct BoundedText {
pub text: String,
pub original_bytes: usize,
pub retained_bytes: usize,
pub truncated: bool,
}Expand description
A byte-bounded, char-boundary-safe view of a string, with exact accounting of what was kept and what was cut.
Fields§
§text: StringThe retained prefix — always valid UTF-8, at most the byte budget.
original_bytes: usizeByte length of the original input.
retained_bytes: usizeByte length of text (≤ budget, ≤ original_bytes).
truncated: boolWhether anything was cut (retained_bytes < original_bytes).
Implementations§
Source§impl BoundedText
impl BoundedText
Sourcepub fn new(s: &str, max_bytes: usize) -> BoundedText
pub fn new(s: &str, max_bytes: usize) -> BoundedText
Truncate s to at most max_bytes bytes at a valid UTF-8 boundary.
Never panics; greedy (keeps the longest prefix that fits).
Trait Implementations§
Source§impl Clone for BoundedText
impl Clone for BoundedText
Source§fn clone(&self) -> BoundedText
fn clone(&self) -> BoundedText
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BoundedText
impl Debug for BoundedText
impl Eq for BoundedText
Source§impl PartialEq for BoundedText
impl PartialEq for BoundedText
impl StructuralPartialEq for BoundedText
Auto Trait Implementations§
impl Freeze for BoundedText
impl RefUnwindSafe for BoundedText
impl Send for BoundedText
impl Sync for BoundedText
impl Unpin for BoundedText
impl UnsafeUnpin for BoundedText
impl UnwindSafe for BoundedText
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.