pub struct IsoStr<C: Charset, const N: usize> { /* private fields */ }Expand description
A space padded string with a fixed length.
Implementations§
Source§impl<C: Charset, const N: usize> IsoStr<C, N>
impl<C: Charset, const N: usize> IsoStr<C, N>
Sourcepub const fn from_bytes_exact(bytes: [u8; N]) -> Self
pub const fn from_bytes_exact(bytes: [u8; N]) -> Self
Performs the from_bytes_exact operation.
Sourcepub fn from_str(s: &str) -> Result<Self, IsoStrError>
pub fn from_str(s: &str) -> Result<Self, IsoStrError>
Performs the from_str operation.
Sourcepub fn from_str_lossy(s: &str) -> Result<Self, IsoStrError>
pub fn from_str_lossy(s: &str) -> Result<Self, IsoStrError>
Like from_str, but auto-converts lowercase to uppercase and substitutes
other invalid characters instead of rejecting them.
Sourcepub fn from_str_unchecked(s: &str) -> Result<Self, IsoStrError>
pub fn from_str_unchecked(s: &str) -> Result<Self, IsoStrError>
Like from_str, but skips charset validation entirely.
Stores the bytes as-is, only checking length.
Sourcepub fn to_str(&self) -> &str
pub fn to_str(&self) -> &str
Borrow the contents as a &str.
§Panics
Panics if the bytes are not valid UTF-8. Because IsoStr is
bytemuck::Pod, instances can be constructed by transmuting raw bytes
from a disk image — those bytes are not guaranteed to be UTF-8 even
when the format requires it. Use Self::try_to_str for a fallible
variant.
Sourcepub fn try_to_str(&self) -> Result<&str, Utf8Error>
pub fn try_to_str(&self) -> Result<&str, Utf8Error>
Borrow the contents as a &str if they are valid UTF-8.
Trait Implementations§
impl<C: Copy + Charset, const N: usize> Copy for IsoStr<C, N>
impl<C: Eq + Charset, const N: usize> Eq for IsoStr<C, N>
impl<C: Charset + 'static, const N: usize> Pod for IsoStr<C, N>
impl<C: PartialEq + Charset, const N: usize> StructuralPartialEq for IsoStr<C, N>
Auto Trait Implementations§
impl<C, const N: usize> Freeze for IsoStr<C, N>
impl<C, const N: usize> RefUnwindSafe for IsoStr<C, N>
impl<C, const N: usize> Send for IsoStr<C, N>
impl<C, const N: usize> Sync for IsoStr<C, N>
impl<C, const N: usize> Unpin for IsoStr<C, N>
impl<C, const N: usize> UnsafeUnpin for IsoStr<C, N>
impl<C, const N: usize> UnwindSafe for IsoStr<C, N>
Blanket Implementations§
impl<T> AnyBitPattern for Twhere
T: Pod,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
If this function returns true, then it must be valid to reinterpret
bits
as &Self.