[][src]Struct fixed_len_str_example::fixed_str_nz12::FixedStrNZ12

#[repr(transparent)]
pub struct FixedStrNZ12 {
    pub array: [NonZeroU8; 12],
}

A fixed length string with a length of 12.

Fields

array: [NonZeroU8; 12]

Methods

impl FixedStrNZ12[src]

pub fn new(array: [NonZeroU8; 12]) -> Result<Self, Utf8Error>[src]

Creates an FixedStrNZ12 from an array,returning an error at invalid utf8.

pub const unsafe fn new_unchecked(array: [NonZeroU8; 12]) -> Self[src]

Creates an FixedStrNZ12 without checking if the bytes are valid utf8.

Safety

Ensure to only use this method with valid utf8.

pub fn as_bytes(&self) -> &[u8][src]

Borrow the internal array as an slice.

pub unsafe fn as_bytes_mut(&mut self) -> &mut [u8][src]

Borrow the internal array as a mutable slice.

Safety

This is unsafe due to allow modifications that can produce invalid utf8.

pub fn into_vec(self) -> Vec<NonZeroU8>[src]

Convert the FixedStrNZ12 into a vector of bytes.

pub fn into_string(self) -> String[src]

Turn the FixedStrNZ12 into a string,moving the bytes.

pub fn from_vec(vec: Vec<NonZeroU8>) -> FixedStrNZ12[src]

Construct a FixedStrNZ12 from a vector of bytes,truncating to adjust the size to 12.

Using this function with multi-byte characters can easely produce an unexpected value.

Panics

This function will panic if the length is less than 12.

pub fn from_string(string: String) -> FixedStrNZ12[src]

Construct a FixedStrNZ12 from a String,truncating to adjust the size to 12.

Using this function with multi-byte characters can easely produce an unexpected value.

pub unsafe fn from_str_unchecked(s: &str) -> FixedStrNZ12[src]

Construct a FixedStrNZ12 from a str,without checking if it has length 12.

Safety

This will trigger UB on str's with length different than 12.

Trait Implementations

impl AsMut<str> for FixedStrNZ12[src]

impl AsRef<str> for FixedStrNZ12[src]

impl Borrow<str> for FixedStrNZ12[src]

impl BorrowMut<str> for FixedStrNZ12[src]

impl Clone for FixedStrNZ12[src]

impl Debug for FixedStrNZ12[src]

impl Deref for FixedStrNZ12[src]

type Target = str

The resulting type after dereferencing.

impl DerefMut for FixedStrNZ12[src]

impl<'de> Deserialize<'de> for FixedStrNZ12[src]

Only expanded in the original crate with the feature "serde_support" enabled.

impl Display for FixedStrNZ12[src]

impl Eq for FixedStrNZ12[src]

impl<'_> From<&'_ str> for FixedStrNZ12[src]

fn from(s: &str) -> Self[src]

Construct a FixedStrNZ12 from a string of length greater or equal to 12,if it is greater will take 12 bytes so be careful with no ascii letters.

Panics

This will panic if the length of s is less than 12 and if it is greater on debug.

impl From<[NonZeroU8; 12]> for FixedStrNZ12[src]

impl From<String> for FixedStrNZ12[src]

impl From<Vec<NonZeroU8>> for FixedStrNZ12[src]

impl Hash for FixedStrNZ12[src]

impl Index<Range<usize>> for FixedStrNZ12[src]

type Output = str

The returned type after indexing.

impl Index<RangeFrom<usize>> for FixedStrNZ12[src]

type Output = str

The returned type after indexing.

impl Index<RangeFull> for FixedStrNZ12[src]

type Output = str

The returned type after indexing.

impl Index<RangeInclusive<usize>> for FixedStrNZ12[src]

type Output = str

The returned type after indexing.

impl Index<RangeTo<usize>> for FixedStrNZ12[src]

type Output = str

The returned type after indexing.

impl Index<RangeToInclusive<usize>> for FixedStrNZ12[src]

type Output = str

The returned type after indexing.

impl IndexMut<Range<usize>> for FixedStrNZ12[src]

impl IndexMut<RangeFrom<usize>> for FixedStrNZ12[src]

impl IndexMut<RangeFull> for FixedStrNZ12[src]

impl IndexMut<RangeInclusive<usize>> for FixedStrNZ12[src]

impl IndexMut<RangeTo<usize>> for FixedStrNZ12[src]

impl IndexMut<RangeToInclusive<usize>> for FixedStrNZ12[src]

impl Ord for FixedStrNZ12[src]

impl<'_> PartialEq<&'_ str> for FixedStrNZ12[src]

impl PartialEq<FixedStrNZ12> for FixedStrNZ12[src]

impl PartialEq<str> for FixedStrNZ12[src]

impl PartialOrd<FixedStrNZ12> for FixedStrNZ12[src]

impl Serialize for FixedStrNZ12[src]

Only expanded in the original crate with the feature "serde_support" enabled.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.