Skip to main content

Name

Struct Name 

Source
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>

Source

pub fn project<'__pin>( self: Pin<&'__pin mut Self>, ) -> NameProjection<'__pin, SIZE>

Pin-projects all fields of Self.

These fields are structurally pinned:

  • lock

These fields are not structurally pinned:

  • name
Source§

impl<const SIZE: usize> Name<SIZE>

Source

pub fn lock_lock(&self) -> impl PinInit<NameLockGuard<'_, SIZE>, Infallible>

Source

pub fn lock_lock_policy<P: LockPolicy<RawSpinlock, AcquireArgs = ()>>( &self, ) -> impl PinInit<NameLockGuard<'_, SIZE, P>, Infallible>

Source

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>

Source

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>

Source

pub fn guard_lock<'b, 'a>( &'b self, token: &'b LockToken<'a, NameLockClass>, ) -> NameLockTokenGuard<'b, 'a, SIZE>

Source

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>

Source

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.

Source

pub fn len(&self) -> usize

Returns the length of the string (excluding the null terminator).

Source

pub fn is_empty(&self) -> bool

Returns true if the string is empty.

Source

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.

Source

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.

Source

pub fn set_str(&self, name: &str)

Resets the Name to the given string slice under lock.

Source

pub fn copy_name(&self) -> [u8; SIZE]

Copies the internal name into a newly stack-allocated buffer of size SIZE.

Source

pub fn copy_from(&self, other: &Self)

Copies the contents of other into self.

Trait Implementations§

Source§

impl<const SIZE: usize> Debug for Name<SIZE>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const SIZE: usize> HasPinData for Name<SIZE>

Source§

type PinData = __ThePinData<SIZE>

Source§

unsafe fn __pin_data() -> Self::PinData

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 T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Init<T> for T

Source§

unsafe fn __init(self, slot: *mut T) -> Result<(), !>

Initializes slot. Read more
Source§

fn chain<F>(self, f: F) -> ChainInit<Self, F, T, E>
where F: FnOnce(&mut T) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

Source§

impl<T> PinInit<T> for T

Source§

unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), !>

Initializes slot. Read more
Source§

fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>
where F: FnOnce(Pin<&mut T>) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
Source§

impl<T> ToMutPtr for T
where T: ?Sized,

Source§

type Target = T

The target type of the pointer.
Source§

fn to_mut_ptr(&self) -> *mut T

Casts the reference to a mutable raw pointer.
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = !

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.