pub struct BaseFixedString<C, const N: usize>where
C: BinRead + BinWrite + Copy + Clone + Default + 'static + Sized,
for<'a> <C as BinRead>::Args<'a>: Default + Clone,
for<'b> <C as BinWrite>::Args<'b>: Default + Clone,{ /* private fields */ }Expand description
Fixed-size string with a specified character type and length.
The string always takes up exactly N characters, with unused characters filled with default values of the character type.
Notes:
From<&str>trims or pads the string to fit exactly N characters.TryInto<String>only pads with default values, it does not trim.
Implementations§
Source§impl<C, const N: usize> BaseFixedString<C, N>
impl<C, const N: usize> BaseFixedString<C, N>
Sourcepub const SIZE_BYTES: usize
pub const SIZE_BYTES: usize
The size of the FixedString in memory, in bytes.
This is also it’s size when bin-read or bin-written.
Sourcepub const MAX_CHARS: usize = N
pub const MAX_CHARS: usize = N
The maximum number of characters in the FixedString.
This is the very same as the generic const parameter N.
Sourcepub fn from_slice(slice: &[C]) -> Self
pub fn from_slice(slice: &[C]) -> Self
Creates a new FixedString from a slice.
If the slice is shorter than N, the remaining bytes are filled with default values. If the slice is longer than N, it is truncated.
Trait Implementations§
Source§impl<C, const N: usize> BinRead for BaseFixedString<C, N>
impl<C, const N: usize> BinRead for BaseFixedString<C, N>
Source§fn read_options<R: Read + Seek>(
__binrw_generated_var_reader: &mut R,
__binrw_generated_var_endian: Endian,
__binrw_generated_var_arguments: Self::Args<'_>,
) -> BinResult<Self>
fn read_options<R: Read + Seek>( __binrw_generated_var_reader: &mut R, __binrw_generated_var_endian: Endian, __binrw_generated_var_arguments: Self::Args<'_>, ) -> BinResult<Self>
Source§fn read_be<R>(reader: &mut R) -> Result<Self, Error>
fn read_be<R>(reader: &mut R) -> Result<Self, Error>
Read
Self from the reader using default arguments and assuming
big-endian byte order. Read moreSource§fn read_le<R>(reader: &mut R) -> Result<Self, Error>
fn read_le<R>(reader: &mut R) -> Result<Self, Error>
Read
Self from the reader using default arguments and assuming
little-endian byte order. Read moreSource§fn read_ne<R>(reader: &mut R) -> Result<Self, Error>
fn read_ne<R>(reader: &mut R) -> Result<Self, Error>
Read
T from the reader assuming native-endian byte order. Read moreSource§fn read_be_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
fn read_be_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
Read
Self from the reader, assuming big-endian byte order, using the
given arguments. Read moreSource§impl<C, const N: usize> BinWrite for BaseFixedString<C, N>
impl<C, const N: usize> BinWrite for BaseFixedString<C, N>
Source§fn write_options<W: Write + Seek>(
&self,
__binrw_generated_var_writer: &mut W,
__binrw_generated_var_endian: Endian,
__binrw_generated_var_arguments: Self::Args<'_>,
) -> BinResult<()>
fn write_options<W: Write + Seek>( &self, __binrw_generated_var_writer: &mut W, __binrw_generated_var_endian: Endian, __binrw_generated_var_arguments: Self::Args<'_>, ) -> BinResult<()>
Source§fn write_be<W>(&self, writer: &mut W) -> Result<(), Error>
fn write_be<W>(&self, writer: &mut W) -> Result<(), Error>
Write
Self to the writer assuming big-endian byte order. Read moreSource§fn write_le<W>(&self, writer: &mut W) -> Result<(), Error>
fn write_le<W>(&self, writer: &mut W) -> Result<(), Error>
Write
Self to the writer assuming little-endian byte order. Read moreSource§fn write_ne<W>(&self, writer: &mut W) -> Result<(), Error>
fn write_ne<W>(&self, writer: &mut W) -> Result<(), Error>
Write
Self to the writer assuming native-endian byte order. Read moreSource§fn write_be_args<W>(
&self,
writer: &mut W,
args: Self::Args<'_>,
) -> Result<(), Error>
fn write_be_args<W>( &self, writer: &mut W, args: Self::Args<'_>, ) -> Result<(), Error>
Write
Self to the writer, assuming big-endian byte order, using the
given arguments. Read moreSource§impl<C, const N: usize> Clone for BaseFixedString<C, N>
impl<C, const N: usize> Clone for BaseFixedString<C, N>
Source§fn clone(&self) -> BaseFixedString<C, N>
fn clone(&self) -> BaseFixedString<C, N>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<C, const N: usize> Debug for BaseFixedString<C, N>
impl<C, const N: usize> Debug for BaseFixedString<C, N>
Source§impl<C, const N: usize> Default for BaseFixedString<C, N>
impl<C, const N: usize> Default for BaseFixedString<C, N>
Source§impl<C, const N: usize> PartialEq for BaseFixedString<C, N>
impl<C, const N: usize> PartialEq for BaseFixedString<C, N>
impl<C, const N: usize> Eq for BaseFixedString<C, N>
impl<C, const N: usize> StructuralPartialEq for BaseFixedString<C, N>
Auto Trait Implementations§
impl<C, const N: usize> Freeze for BaseFixedString<C, N>
impl<C, const N: usize> RefUnwindSafe for BaseFixedString<C, N>
impl<C, const N: usize> Send for BaseFixedString<C, N>
impl<C, const N: usize> Sync for BaseFixedString<C, N>
impl<C, const N: usize> Unpin for BaseFixedString<C, N>
impl<C, const N: usize> UnwindSafe for BaseFixedString<C, N>
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