Trait polymock::buf::Buf

source ·
pub trait Buf {
Show 43 methods // Required methods fn advance(&mut self, cnt: usize); fn chunk(&self) -> &[u8] ; fn remaining(&self) -> usize; // Provided methods fn copy_to_bytes(&mut self, len: usize) -> Bytes { ... } fn copy_to_slice(&mut self, dst: &mut [u8]) { ... } fn get_f32(&mut self) -> f32 { ... } fn get_f32_le(&mut self) -> f32 { ... } fn get_f32_ne(&mut self) -> f32 { ... } fn get_f64(&mut self) -> f64 { ... } fn get_f64_le(&mut self) -> f64 { ... } fn get_f64_ne(&mut self) -> f64 { ... } fn get_u8(&mut self) -> u8 { ... } fn get_u8_le(&mut self) -> u8 { ... } fn get_u8_ne(&mut self) -> u8 { ... } fn get_u16(&mut self) -> u16 { ... } fn get_u16_le(&mut self) -> u16 { ... } fn get_u16_ne(&mut self) -> u16 { ... } fn get_u32(&mut self) -> u32 { ... } fn get_u32_le(&mut self) -> u32 { ... } fn get_u32_ne(&mut self) -> u32 { ... } fn get_u64(&mut self) -> u64 { ... } fn get_u64_le(&mut self) -> u64 { ... } fn get_u64_ne(&mut self) -> u64 { ... } fn get_u128(&mut self) -> u128 { ... } fn get_u128_le(&mut self) -> u128 { ... } fn get_u128_ne(&mut self) -> u128 { ... } fn get_i8(&mut self) -> i8 { ... } fn get_i8_le(&mut self) -> i8 { ... } fn get_i8_ne(&mut self) -> i8 { ... } fn get_i16(&mut self) -> i16 { ... } fn get_i16_le(&mut self) -> i16 { ... } fn get_i16_ne(&mut self) -> i16 { ... } fn get_i32(&mut self) -> i32 { ... } fn get_i32_le(&mut self) -> i32 { ... } fn get_i32_ne(&mut self) -> i32 { ... } fn get_i64(&mut self) -> i64 { ... } fn get_i64_le(&mut self) -> i64 { ... } fn get_i64_ne(&mut self) -> i64 { ... } fn get_i128(&mut self) -> i128 { ... } fn get_i128_le(&mut self) -> i128 { ... } fn get_i128_ne(&mut self) -> i128 { ... } fn has_remaining(&self) -> bool { ... } fn reader(self) -> Reader<Self> where Self: Sized { ... }
}
Expand description

A readable memory buffer.

Buf is a cursor to a readable memory buffer. It exposes functions to read and move the cursor forward.

This is a mostly drop-in replacement for bytes::Buf. Buf will be deprecated once the bytes crate can be used with custom vtables. See crate level docs for more details.

Required Methods§

source

fn advance(&mut self, cnt: usize)

Advances the cursor of the buffer by cnt bytes.

source

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

Returns a slice, starting at the current position and a length of Buf::remaining().

source

fn remaining(&self) -> usize

Returns the number of remaining bytes in the buffer.

Provided Methods§

source

fn copy_to_bytes(&mut self, len: usize) -> Bytes

Consumes and Returns the first len as a Bytes.

source

fn copy_to_slice(&mut self, dst: &mut [u8])

Copy bytes from the buffer into dst.

Panics

Panics if self.remaining() < dst.len().

source

fn get_f32(&mut self) -> f32

Takes an f32 from the buffer in big-endian order.

Panics

Panics if self.remaining() < 4.

source

fn get_f32_le(&mut self) -> f32

Takes an f32 from the buffer in little-endian order.

Panics

Panics if self.remaining() < 4.

source

fn get_f32_ne(&mut self) -> f32

Takes an f32 from the buffer in native-endian order.

Panics

Panics if self.remaining() < 4.

source

fn get_f64(&mut self) -> f64

Takes an f64 from the buffer in big-endian order.

Panics

Panics if self.remaining() < 8.

source

fn get_f64_le(&mut self) -> f64

Takes an f64 from the buffer in little-endian order.

Panics

Panics if self.remaining() < 8.

source

fn get_f64_ne(&mut self) -> f64

Takes an f64 from the buffer in native-endian order.

Panics

Panics if self.remaining() < 8.

source

fn get_u8(&mut self) -> u8

Takes an u8 from the buffer in big-endian order.

Panics

Panics if self.remaining() < 1.

source

fn get_u8_le(&mut self) -> u8

Takes an u8 from the buffer in little-endian order.

Panics

Panics if self.remaining() < 1.

source

fn get_u8_ne(&mut self) -> u8

Takes an u8 from the buffer in native-endian order.

Panics

Panics if self.remaining() < 1.

source

fn get_u16(&mut self) -> u16

Takes an u16 from the buffer in big-endian order.

Panics

Panics if self.remaining() < 2.

source

fn get_u16_le(&mut self) -> u16

Takes an u16 from the buffer in little-endian order.

Panics

Panics if self.remaining() < 2.

source

fn get_u16_ne(&mut self) -> u16

Takes an u16 from the buffer in native-endian order.

Panics

Panics if self.remaining() < 2.

source

fn get_u32(&mut self) -> u32

Takes an u32 from the buffer in big-endian order.

Panics

Panics if self.remaining() < 4.

source

fn get_u32_le(&mut self) -> u32

Takes an u32 from the buffer in little-endian order.

Panics

Panics if self.remaining() < 4.

source

fn get_u32_ne(&mut self) -> u32

Takes an u32 from the buffer in native-endian order.

Panics

Panics if self.remaining() < 4.

source

fn get_u64(&mut self) -> u64

Takes an u64 from the buffer in big-endian order.

Panics

Panics if self.remaining() < 8.

source

fn get_u64_le(&mut self) -> u64

Takes an u64 from the buffer in little-endian order.

Panics

Panics if self.remaining() < 8.

source

fn get_u64_ne(&mut self) -> u64

Takes an u64 from the buffer in native-endian order.

Panics

Panics if self.remaining() < 8.

source

fn get_u128(&mut self) -> u128

Takes an u128 from the buffer in big-endian order.

Panics

Panics if self.remaining() < 16.

source

fn get_u128_le(&mut self) -> u128

Takes an u128 from the buffer in little-endian order.

Panics

Panics if self.remaining() < 16.

source

fn get_u128_ne(&mut self) -> u128

Takes an u128 from the buffer in native-endian order.

Panics

Panics if self.remaining() < 16.

source

fn get_i8(&mut self) -> i8

Takes an i8 from the buffer in big-endian order.

Panics

Panics if self.remaining() < 1.

source

fn get_i8_le(&mut self) -> i8

Takes an i8 from the buffer in little-endian order.

Panics

Panics if self.remaining() < 1.

source

fn get_i8_ne(&mut self) -> i8

Takes an i8 from the buffer in native-endian order.

Panics

Panics if self.remaining() < 1.

source

fn get_i16(&mut self) -> i16

Takes an i16 from the buffer in big-endian order.

Panics

Panics if self.remaining() < 2.

source

fn get_i16_le(&mut self) -> i16

Takes an i16 from the buffer in little-endian order.

Panics

Panics if self.remaining() < 2.

source

fn get_i16_ne(&mut self) -> i16

Takes an i16 from the buffer in native-endian order.

Panics

Panics if self.remaining() < 2.

source

fn get_i32(&mut self) -> i32

Takes an i32 from the buffer in big-endian order.

Panics

Panics if self.remaining() < 4.

source

fn get_i32_le(&mut self) -> i32

Takes an i32 from the buffer in little-endian order.

Panics

Panics if self.remaining() < 4.

source

fn get_i32_ne(&mut self) -> i32

Takes an i32 from the buffer in native-endian order.

Panics

Panics if self.remaining() < 4.

source

fn get_i64(&mut self) -> i64

Takes an i64 from the buffer in big-endian order.

Panics

Panics if self.remaining() < 8.

source

fn get_i64_le(&mut self) -> i64

Takes an i64 from the buffer in little-endian order.

Panics

Panics if self.remaining() < 8.

source

fn get_i64_ne(&mut self) -> i64

Takes an i64 from the buffer in native-endian order.

Panics

Panics if self.remaining() < 8.

source

fn get_i128(&mut self) -> i128

Takes an i128 from the buffer in big-endian order.

Panics

Panics if self.remaining() < 16.

source

fn get_i128_le(&mut self) -> i128

Takes an i128 from the buffer in little-endian order.

Panics

Panics if self.remaining() < 16.

source

fn get_i128_ne(&mut self) -> i128

Takes an i128 from the buffer in native-endian order.

Panics

Panics if self.remaining() < 16.

source

fn has_remaining(&self) -> bool

Returns true if this buffer has bytes remaining.

source

fn reader(self) -> Reader<Self> where Self: Sized,

Available on crate feature std only.

Creates a Reader, that implements Read and BufRead.

Implementations on Foreign Types§

source§

impl<T> Buf for &mut Twhere T: ?Sized + Buf,

source§

fn advance(&mut self, cnt: usize)

source§

fn remaining(&self) -> usize

source§

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

source§

impl<T> Buf for Box<T>where T: ?Sized + Buf,

source§

fn advance(&mut self, cnt: usize)

source§

fn remaining(&self) -> usize

source§

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

source§

impl Buf for &[u8]

source§

fn remaining(&self) -> usize

source§

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

source§

fn advance(&mut self, cnt: usize)

Implementors§