[][src]Struct fixed_len_str_example::FixedStr12

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

A fixed length string with a length of 12.

Fields

array: [u8; 12]

Methods

impl FixedStr12[src]

pub const fn new(array: [u8; 12]) -> Self[src]

Creates an FixedStr12 from an array,in the future this will be unsafe because it does not checks if the bytes are 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 fill_zeroes_char(&mut self, character: char)[src]

Fill the last spaces in zero of the buffer with a determinated character.Useful when constructing the array with all bytes in zero and then filling them in an incremental way.

Panics

This will panic on debug if the zero spaces are not sufficient for the non-zero spaces of the character interpreted as \[u8; 4\].

pub fn fill_zeroes_str(&mut self, s: &str)[src]

Fill the last spaces in zero of the buffer with a determinated string.Useful when constructing the array with all bytes in zero and then filling them in an incremental way.

Panics

This will panic on debug if the zero spaces are not sufficient for the non-zero spaces of the string interpreted as &\[u8\].

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

Convert the FixedStr12 into a vector of bytes.

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

Turn the FixedStr12 into a string,moving the bytes.

pub fn from_vec(vec: Vec<u8>) -> FixedStr12[src]

Construct a FixedStr12 from a vector of bytes,truncating or pushing zeroes to adjust the size to 12.

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

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

Construct a FixedStr12 from a String,truncating or pushing zeroes to adjust the size to 12.

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

Trait Implementations

impl AsMut<str> for FixedStr12[src]

impl AsRef<str> for FixedStr12[src]

impl Clone for FixedStr12[src]

impl Debug for FixedStr12[src]

impl Default for FixedStr12[src]

impl Deref for FixedStr12[src]

type Target = str

The resulting type after dereferencing.

impl DerefMut for FixedStr12[src]

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

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

impl Display for FixedStr12[src]

impl Eq for FixedStr12[src]

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

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

Reinterprets the bytes of s as &[u8; 12] then dereferences and pass that to the constructor of FixedStr12.

Panics

This will panic if the length of s is different than 12 on debug.

impl From<String> for FixedStr12[src]

impl From<Vec<u8>> for FixedStr12[src]

impl Hash for FixedStr12[src]

impl Ord for FixedStr12[src]

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

impl PartialEq<FixedStr12> for FixedStr12[src]

impl PartialEq<str> for FixedStr12[src]

impl PartialOrd<FixedStr12> for FixedStr12[src]

impl Serialize for FixedStr12[src]

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

impl StructuralEq for FixedStr12[src]

impl StructuralPartialEq for FixedStr12[src]

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.