Skip to main content

NullTerminatedBuf

Struct NullTerminatedBuf 

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

A null terminated memory buffer.

Implementations§

Source§

impl NullTerminatedBuf

Source

pub fn from_reader(reader: &mut dyn Read) -> Result<NullTerminatedBuf, Error>

Create from a reader and null terminate.

Source

pub fn from_file(f: &mut File) -> Result<NullTerminatedBuf, Error>

Create from a file and null terminate it.

Source

pub fn from_slice_copy(s: &[u8]) -> NullTerminatedBuf

Create by copying a slice and appending null-termination.

Source

pub fn from_slice_check(s: &[u8]) -> NullTerminatedBuf

Create from a slice that may already be null-terminated.

Source

pub fn from_str_copy(s: &str) -> NullTerminatedBuf

Create by copying a string and appending null-termination.

Source

pub fn from_str_check(s: &str) -> NullTerminatedBuf

Create from a string that may already be null-terminated.

Source

pub fn len(&self) -> usize

Return the length of the data including the null terminator.

Source

pub fn is_empty(&self) -> bool

Just a placeholder always returning true, since the there is always at least a null terminator.

Source

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

Trait Implementations§

Source§

impl AsRef<[u8]> for NullTerminatedBuf

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Debug for NullTerminatedBuf

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.