pub struct FixedFilename<const N: usize> {
pub data: [u8; N],
pub len: usize,
}Expand description
A fixed-length, stack-allocated filename buffer.
Stores up to N bytes of filename data on the stack without
heap allocation. Useful for no-std filesystem implementations
where filenames have a known maximum length.
§Example
use hadris_common::types::file::FixedFilename;
let name = FixedFilename::<64>::from(b"readme.txt".as_slice());
assert_eq!(name.len(), 10);
assert_eq!(name.as_str(), "readme.txt");
assert!(!name.is_empty());Fields§
§data: [u8; N]§len: usizeImplementations§
Source§impl<const N: usize> FixedFilename<N>
impl<const N: usize> FixedFilename<N>
pub const fn empty() -> Self
pub const fn with_size(size: usize) -> Self
pub fn as_str(&self) -> &str
pub fn allocate(&mut self, bytes: usize)
pub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
pub fn truncate(&mut self, new_size: usize)
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn push_slice(&mut self, slice: &[u8]) -> Range<usize>
pub fn push_byte(&mut self, b: u8) -> usize
pub fn try_push_slice(&mut self, slice: &[u8]) -> Option<Range<usize>>
pub fn try_push_byte(&mut self, b: u8) -> Option<usize>
pub fn remaining_capacity(&self) -> usize
Trait Implementations§
Source§impl<const N: usize> Clone for FixedFilename<N>
impl<const N: usize> Clone for FixedFilename<N>
Source§fn clone(&self) -> FixedFilename<N>
fn clone(&self) -> FixedFilename<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<const N: usize> Debug for FixedFilename<N>
impl<const N: usize> Debug for FixedFilename<N>
Source§impl<const N: usize> Display for FixedFilename<N>
impl<const N: usize> Display for FixedFilename<N>
Source§impl<const N: usize> PartialEq for FixedFilename<N>
impl<const N: usize> PartialEq for FixedFilename<N>
impl<const N: usize> Copy for FixedFilename<N>
impl<const N: usize> Eq for FixedFilename<N>
impl<const N: usize> StructuralPartialEq for FixedFilename<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for FixedFilename<N>
impl<const N: usize> RefUnwindSafe for FixedFilename<N>
impl<const N: usize> Send for FixedFilename<N>
impl<const N: usize> Sync for FixedFilename<N>
impl<const N: usize> Unpin for FixedFilename<N>
impl<const N: usize> UnsafeUnpin for FixedFilename<N>
impl<const N: usize> UnwindSafe for FixedFilename<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