pub enum Text<'a> {
Sanitized(Cow<'a, str>),
Trusted(Cow<'a, str>),
}Expand description
Text with trust level annotation.
Use this to explicitly mark whether text has been sanitized or comes from a trusted source.
Variants§
Sanitized(Cow<'a, str>)
Sanitized text (escape sequences stripped).
Trusted(Cow<'a, str>)
Trusted text (may contain ANSI sequences). Only use with content from trusted sources.
Implementations§
Source§impl<'a> Text<'a>
impl<'a> Text<'a>
Sourcepub fn trusted(s: &'a str) -> Self
pub fn trusted(s: &'a str) -> Self
Create from a trusted source (ANSI sequences allowed).
§Safety
Only use with content from trusted sources. Untrusted content can corrupt terminal state or deceive users.
Sourcepub fn sanitized_owned(s: String) -> Self
pub fn sanitized_owned(s: String) -> Self
Create owned sanitized text.
Sourcepub fn trusted_owned(s: String) -> Self
pub fn trusted_owned(s: String) -> Self
Create owned trusted text.
Sourcepub fn is_sanitized(&self) -> bool
pub fn is_sanitized(&self) -> bool
Check if this text is sanitized.
Sourcepub fn is_trusted(&self) -> bool
pub fn is_trusted(&self) -> bool
Check if this text is trusted.
Sourcepub fn into_owned(self) -> Text<'static>
pub fn into_owned(self) -> Text<'static>
Convert to owned version.
Trait Implementations§
impl<'a> Eq for Text<'a>
impl<'a> StructuralPartialEq for Text<'a>
Auto Trait Implementations§
impl<'a> Freeze for Text<'a>
impl<'a> RefUnwindSafe for Text<'a>
impl<'a> Send for Text<'a>
impl<'a> Sync for Text<'a>
impl<'a> Unpin for Text<'a>
impl<'a> UnwindSafe for Text<'a>
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