pub struct Name<const SIZE: usize> { /* private fields */ }Expand description
A fixed-size, thread-safe name buffer with automatic truncation and null-termination.
Names include the trailing null byte as part of their SIZE-sized buffer.
Constructors and setters automatically truncate inputs to SIZE - 1 bytes to ensure
the string is always null-terminated.
Corresponds to fbl::Name<Size> in C++.
Implementations§
Source§impl<const SIZE: usize> Name<SIZE>
impl<const SIZE: usize> Name<SIZE>
pub fn lock_lock(&self) -> impl PinInit<NameLockGuard<'_, SIZE>, Infallible>
pub fn lock_lock_policy<P: LockPolicy<RawSpinlock, AcquireArgs = ()>>( &self, ) -> impl PinInit<NameLockGuard<'_, SIZE, P>, Infallible>
pub fn lock_lock_aliased<'a, AliasClass: LockClass, M2: RawLock>( &'a self, alias: &'a KMutex<AliasClass, M2>, ) -> impl PinInit<KMutexAliasedGuard<'a, NameLockClass, AliasClass, RawSpinlock, M2>, Infallible>
pub fn lock_lock_aliased_policy<'a, AliasClass: LockClass, M2: RawLock, P: LockPolicy<RawSpinlock, AcquireArgs = ()>>( &'a self, alias: &'a KMutex<AliasClass, M2>, ) -> impl PinInit<KMutexAliasedGuard<'a, NameLockClass, AliasClass, RawSpinlock, M2, P>, Infallible>
pub fn guard_lock<'b, 'a>( &'b self, token: &'b LockToken<'a, NameLockClass>, ) -> NameLockTokenGuard<'b, 'a, SIZE>
pub fn guard_lock_mut<'b, 'a>( &'b self, token: &'b mut LockToken<'a, NameLockClass>, ) -> NameLockTokenGuardMut<'b, 'a, SIZE>
Source§impl<const SIZE: usize> Name<SIZE>
impl<const SIZE: usize> Name<SIZE>
Sourcepub fn init() -> impl PinInit<Self, Infallible>
pub fn init() -> impl PinInit<Self, Infallible>
Creates a PinInit initializer for Name initialized to an empty string.
Initializes storage directly in-place without stack copies.
Sourcepub fn get(&self, out_name: &mut [u8])
pub fn get(&self, out_name: &mut [u8])
Copies the name out into out_name.
out_name is zeroed first. If out_name is non-empty, up to
min(out_name.len() - 1, SIZE - 1) characters are copied up to the first null byte.
If out_name is empty, no data is written.
Sourcepub fn set(&self, name: &[u8])
pub fn set(&self, name: &[u8])
Resets the Name to the given data under lock.
Any characters after the first null byte are ignored. If name is longer than
SIZE - 1, it will be truncated to ensure null-termination. The remainder of the
internal buffer is filled with null bytes.
Trait Implementations§
Auto Trait Implementations§
impl<const SIZE: usize> !Freeze for Name<SIZE>
impl<const SIZE: usize> !RefUnwindSafe for Name<SIZE>
impl<const SIZE: usize> Send for Name<SIZE>
impl<const SIZE: usize> Sync for Name<SIZE>
impl<const SIZE: usize> UnsafeUnpin for Name<SIZE>
impl<const SIZE: usize> UnwindSafe for Name<SIZE>
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
Source§impl<T> PinInit<T> for T
impl<T> PinInit<T> for T
Source§unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), !>
unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), !>
slot. Read moreSource§fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>where
F: FnOnce(Pin<&mut T>) -> Result<(), E>,
fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>where
F: FnOnce(Pin<&mut T>) -> Result<(), E>,
self then calls the function f with the initialized
value. Read more