Struct SName

Source
pub struct SName(/* private fields */);
Expand description

A null-terminated string that always maps to the 64 bytes assigned to it in Message.

You can get the string value back out with to_string():

let name: CString = sname.to_string();

Implementations§

Source§

impl SName

Source

pub const EMPTY: Self

A SName that contains all zero bytes.

This is more performant than SName::new(c"")

Source

pub fn new(name: &CStr) -> Result<Self>

Construct a valid sname field. name must not be more 64 bytes.

Source

pub fn from_slice_unchecked(name: &[u8]) -> Self

Converts an array slice of exactly 64 byte length into a SName without performing any checks (such as length or null-termination).

Panics if slice is not 64 bytes.

Useful if you are handling the return of parse_sname.

Source

pub fn to_string(&self) -> CString

Convert the internal array to a null-terminated string representation with padding removed.

Source

pub fn len(&self) -> usize

Get the length of SName.

Note that this returns the length of the inner array which is always 64. To get the length of its string representation call sname.to_string().count_bytes().

Trait Implementations§

Source§

impl Debug for SName

Source§

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

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

impl From<&SName> for [u8; 64]

Source§

fn from(sname: &SName) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for SName

Source§

fn eq(&self, other: &SName) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for SName

Auto Trait Implementations§

§

impl Freeze for SName

§

impl RefUnwindSafe for SName

§

impl Send for SName

§

impl Sync for SName

§

impl Unpin for SName

§

impl UnwindSafe for SName

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V