pub struct PrintableString<S>(/* private fields */);Expand description
A nonempty value of printable ASCII bytes, space included.
Implementations§
Source§impl<S: ImmutableText> PrintableString<S>
impl<S: ImmutableText> PrintableString<S>
Source§impl<'a> PrintableString<&'a str>
impl<'a> PrintableString<&'a str>
Sourcepub fn from_bytes(bytes: &'a [u8]) -> Result<Self, &'static str>
pub fn from_bytes(bytes: &'a [u8]) -> Result<Self, &'static str>
Admit raw bytes. The check stops at the first byte that is not printable ASCII, so it never reads past the end of a printable run.
§Errors
Returns a static message when the bytes are empty or hold another byte.
Sourcepub fn into_owned(self) -> PrintableString<String>
pub fn into_owned(self) -> PrintableString<String>
Copy the checked text into owned storage.
Trait Implementations§
Source§impl<S: Clone> Clone for PrintableString<S>
impl<S: Clone> Clone for PrintableString<S>
impl<S: Copy> Copy for PrintableString<S>
Source§impl<S: Debug> Debug for PrintableString<S>
impl<S: Debug> Debug for PrintableString<S>
Source§impl<'de> Deserialize<'de> for PrintableString<String>
impl<'de> Deserialize<'de> for PrintableString<String>
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl<S: Eq> Eq for PrintableString<S>
Source§impl<S: PartialEq> PartialEq for PrintableString<S>
impl<S: PartialEq> PartialEq for PrintableString<S>
Source§impl<S: ImmutableText> Serialize for PrintableString<S>
impl<S: ImmutableText> Serialize for PrintableString<S>
impl<S: PartialEq> StructuralPartialEq for PrintableString<S>
Auto Trait Implementations§
impl<S> Freeze for PrintableString<S>where
S: Freeze,
impl<S> RefUnwindSafe for PrintableString<S>where
S: RefUnwindSafe,
impl<S> Send for PrintableString<S>where
S: Send,
impl<S> Sync for PrintableString<S>where
S: Sync,
impl<S> Unpin for PrintableString<S>where
S: Unpin,
impl<S> UnsafeUnpin for PrintableString<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for PrintableString<S>where
S: UnwindSafe,
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