pub struct Bytes<'data>(pub &'data [u8]);
Expand description

A newtype for byte slices.

It has these important features:

  • no methods that can panic, such as Index
  • convenience methods for Pod types
  • a useful Debug implementation

Tuple Fields

0: &'data [u8]

Implementations

Return the length of the byte slice.

Return true if the byte slice is empty.

Skip over the given number of bytes at the start of the byte slice.

Modifies the byte slice to start after the bytes.

Returns an error if there are too few bytes.

Return a reference to the given number of bytes at the start of the byte slice.

Modifies the byte slice to start after the bytes.

Returns an error if there are too few bytes.

Return a reference to the given number of bytes at the given offset of the byte slice.

Returns an error if the offset is invalid or there are too few bytes.

Return a reference to a Pod struct at the start of the byte slice.

Modifies the byte slice to start after the bytes.

Returns an error if there are too few bytes or the slice is incorrectly aligned.

Return a reference to a Pod struct at the given offset of the byte slice.

Returns an error if there are too few bytes or the offset is incorrectly aligned.

Return a reference to a slice of Pod structs at the start of the byte slice.

Modifies the byte slice to start after the bytes.

Returns an error if there are too few bytes or the offset is incorrectly aligned.

Return a reference to a slice of Pod structs at the given offset of the byte slice.

Returns an error if there are too few bytes or the offset is incorrectly aligned.

Read a null terminated string.

Does not assume any encoding. Reads past the null byte, but doesn’t return it.

Read a null terminated string at an offset.

Does not assume any encoding. Does not return the null byte.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.