Struct BodyBytes

Source
pub struct BodyBytes<'a> { /* private fields */ }
Expand description

Read more from a body.

Implementations§

Source§

impl<'a> BodyBytes<'a>

Source

pub fn new(slice: &'a [u8]) -> Self

Creates a new body bytes.

Source

pub fn len(&self) -> usize

Returns the length of this body.

Source

pub fn inner(&self) -> &'a [u8]

returns the inner slice

Source

pub fn deserialize<D>(&self) -> Result<D>

Available on crate feature json only.
Source

pub async fn to_file<P>(&mut self, path: P) -> Result<()>
where P: AsRef<Path>,

Available on crate feature fs only.

Trait Implementations§

Source§

impl BytesRead for BodyBytes<'_>

Source§

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

Returns the entire slice.
Source§

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

Returns all remaining bytes.
Source§

fn try_read(&mut self, len: usize) -> StdResult<&[u8], ReadError>

Try to read a given length of bytes. Read more
Source§

fn peek(&self, len: usize) -> Option<&[u8]>

Tries to read a given length without updating the internal position. Returns None if there are not enought bytes remaining.
Source§

fn len(&self) -> usize

Returns the length of the entire slice.
Source§

fn read(&mut self, len: usize) -> &[u8]

Reads a given length of bytes. Read more
Source§

fn try_read_u8(&mut self) -> Result<u8, ReadError>

Try to read 1 bytes in big-endian converting them into an u8.
Source§

fn read_u8(&mut self) -> u8

Reads 1 bytes in big-endian converting them into an u8. Read more
Source§

fn try_read_u16(&mut self) -> Result<u16, ReadError>

Try to read 2 bytes in big-endian converting them into an u16.
Source§

fn read_u16(&mut self) -> u16

Reads 2 bytes in big-endian converting them into an u16. Read more
Source§

fn try_read_u32(&mut self) -> Result<u32, ReadError>

Try to read 4 bytes in big-endian converting them into an u32.
Source§

fn read_u32(&mut self) -> u32

Reads 4 bytes in big-endian converting them into an u32. Read more
Source§

fn try_read_u64(&mut self) -> Result<u64, ReadError>

Try to read 8 bytes in big-endian converting them into an u64.
Source§

fn read_u64(&mut self) -> u64

Reads 8 bytes in big-endian converting them into an u64. Read more
Source§

fn try_read_u128(&mut self) -> Result<u128, ReadError>

Try to read 16 bytes in big-endian converting them into an u128.
Source§

fn read_u128(&mut self) -> u128

Reads 16 bytes in big-endian converting them into an u128. Read more
Source§

fn try_read_i8(&mut self) -> Result<i8, ReadError>

Try to read 1 bytes in big-endian converting them into an i8.
Source§

fn read_i8(&mut self) -> i8

Reads 1 bytes in big-endian converting them into an i8. Read more
Source§

fn try_read_i16(&mut self) -> Result<i16, ReadError>

Try to read 2 bytes in big-endian converting them into an i16.
Source§

fn read_i16(&mut self) -> i16

Reads 2 bytes in big-endian converting them into an i16. Read more
Source§

fn try_read_i32(&mut self) -> Result<i32, ReadError>

Try to read 4 bytes in big-endian converting them into an i32.
Source§

fn read_i32(&mut self) -> i32

Reads 4 bytes in big-endian converting them into an i32. Read more
Source§

fn try_read_i64(&mut self) -> Result<i64, ReadError>

Try to read 8 bytes in big-endian converting them into an i64.
Source§

fn read_i64(&mut self) -> i64

Reads 8 bytes in big-endian converting them into an i64. Read more
Source§

fn try_read_i128(&mut self) -> Result<i128, ReadError>

Try to read 16 bytes in big-endian converting them into an i128.
Source§

fn read_i128(&mut self) -> i128

Reads 16 bytes in big-endian converting them into an i128. Read more
Source§

fn try_read_f32(&mut self) -> Result<f32, ReadError>

Try to read 4 bytes in big-endian converting them into an f32.
Source§

fn read_f32(&mut self) -> f32

Reads 4 bytes in big-endian converting them into an f32. Read more
Source§

fn try_read_f64(&mut self) -> Result<f64, ReadError>

Try to read 8 bytes in big-endian converting them into an f64.
Source§

fn read_f64(&mut self) -> f64

Reads 8 bytes in big-endian converting them into an f64. Read more
Source§

fn try_read_le_u8(&mut self) -> Result<u8, ReadError>

Try to read 1 bytes in little-endian converting them into an u8.
Source§

fn read_le_u8(&mut self) -> u8

Reads 1 bytes in little-endian converting them into an u8. Read more
Source§

fn try_read_le_u16(&mut self) -> Result<u16, ReadError>

Try to read 2 bytes in little-endian converting them into an u16.
Source§

fn read_le_u16(&mut self) -> u16

Reads 2 bytes in little-endian converting them into an u16. Read more
Source§

fn try_read_le_u32(&mut self) -> Result<u32, ReadError>

Try to read 4 bytes in little-endian converting them into an u32.
Source§

fn read_le_u32(&mut self) -> u32

Reads 4 bytes in little-endian converting them into an u32. Read more
Source§

fn try_read_le_u64(&mut self) -> Result<u64, ReadError>

Try to read 8 bytes in little-endian converting them into an u64.
Source§

fn read_le_u64(&mut self) -> u64

Reads 8 bytes in little-endian converting them into an u64. Read more
Source§

fn try_read_le_u128(&mut self) -> Result<u128, ReadError>

Try to read 16 bytes in little-endian converting them into an u128.
Source§

fn read_le_u128(&mut self) -> u128

Reads 16 bytes in little-endian converting them into an u128. Read more
Source§

fn try_read_le_i8(&mut self) -> Result<i8, ReadError>

Try to read 1 bytes in little-endian converting them into an i8.
Source§

fn read_le_i8(&mut self) -> i8

Reads 1 bytes in little-endian converting them into an i8. Read more
Source§

fn try_read_le_i16(&mut self) -> Result<i16, ReadError>

Try to read 2 bytes in little-endian converting them into an i16.
Source§

fn read_le_i16(&mut self) -> i16

Reads 2 bytes in little-endian converting them into an i16. Read more
Source§

fn try_read_le_i32(&mut self) -> Result<i32, ReadError>

Try to read 4 bytes in little-endian converting them into an i32.
Source§

fn read_le_i32(&mut self) -> i32

Reads 4 bytes in little-endian converting them into an i32. Read more
Source§

fn try_read_le_i64(&mut self) -> Result<i64, ReadError>

Try to read 8 bytes in little-endian converting them into an i64.
Source§

fn read_le_i64(&mut self) -> i64

Reads 8 bytes in little-endian converting them into an i64. Read more
Source§

fn try_read_le_i128(&mut self) -> Result<i128, ReadError>

Try to read 16 bytes in little-endian converting them into an i128.
Source§

fn read_le_i128(&mut self) -> i128

Reads 16 bytes in little-endian converting them into an i128. Read more
Source§

fn try_read_le_f32(&mut self) -> Result<f32, ReadError>

Try to read 4 bytes in little-endian converting them into an f32.
Source§

fn read_le_f32(&mut self) -> f32

Reads 4 bytes in little-endian converting them into an f32. Read more
Source§

fn try_read_le_f64(&mut self) -> Result<f64, ReadError>

Try to read 8 bytes in little-endian converting them into an f64.
Source§

fn read_le_f64(&mut self) -> f64

Reads 8 bytes in little-endian converting them into an f64. Read more
Source§

impl<'a> BytesReadRef<'a> for BodyBytes<'a>

Source§

fn as_slice_ref(&self) -> &'a [u8]

Returns the entire slice.
Source§

fn remaining_ref(&self) -> &'a [u8]

Returns all remaining bytes.
Source§

fn try_read_ref(&mut self, len: usize) -> StdResult<&'a [u8], ReadError>

Try to read a given length of bytes. Read more
Source§

fn peek_ref(&self, len: usize) -> Option<&'a [u8]>

Tries to read a given length without updating the internal position. Returns None if there are not enought bytes remaining.
Source§

fn read_ref(&mut self, len: usize) -> &'a [u8]

Reads a given length of bytes. Read more
Source§

impl BytesSeek for BodyBytes<'_>

Source§

fn position(&self) -> usize

Returns the internal position.
Source§

fn try_seek(&mut self, pos: usize) -> StdResult<(), SeekError>

Sets the internal position if possible.
Source§

fn seek(&mut self, pos: usize)

Sets the internal position.
Source§

fn try_advance(&mut self, adv: usize) -> Result<(), SeekError>

Advances the internal position if possible.
Source§

fn advance(&mut self, adv: usize)

Advances the internal position. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for BodyBytes<'a>

§

impl<'a> RefUnwindSafe for BodyBytes<'a>

§

impl<'a> Send for BodyBytes<'a>

§

impl<'a> Sync for BodyBytes<'a>

§

impl<'a> Unpin for BodyBytes<'a>

§

impl<'a> UnwindSafe for BodyBytes<'a>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more