Struct File

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

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

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

let path: CString = file.to_string();

Implementations§

Source§

impl File

Source

pub const EMPTY: Self

A File that contains all zero bytes.

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

Source

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

Construct a valid file field. path must not be more than 128 bytes. The last byte of which must be 0x00 (null-terminated).

Source

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

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

Panics if slice is not 128 bytes.

Useful if you are handling the return of parse_file.

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 File.

Note that this returns the length of the inner array which is always 128. To get the length of its string representation call file.to_string().len().

Trait Implementations§

Source§

impl Debug for File

Source§

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

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

impl From<&File> for [u8; 128]

Source§

fn from(file: &File) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for File

Source§

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

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

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 File

Auto Trait Implementations§

§

impl Freeze for File

§

impl RefUnwindSafe for File

§

impl Send for File

§

impl Sync for File

§

impl Unpin for File

§

impl UnwindSafe for File

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