Segment

Struct Segment 

Source
pub struct Segment<'s, I> { /* private fields */ }
Expand description

A segment of a crate::Source.

This is where data is actually read from. Each segment keeps track of a few things:

  1. An initial offset (retrievable via Segment::initial_offset).
  2. A cursor (retrievable via Segment::current_offset).
  3. A reference to the source’s data.

§Index op

Like slices, Segments support indexes via usizes or ranges. A few important things to note about this:

  1. The value(s) provided should be offsets (see the crate’s top-level documentation for more info and what this means).
  2. Unlike with a Segment’s various methods, no validation of the provided offset occurs, potentially leading to a panic.

Implementations§

Source§

impl<'s> Segment<'s, u8>

Source

pub fn with_endidness(data: &'s [u8], endidness: Endidness) -> Self

Creates a new Segment using the provided endidness.

Note: Only available if the Segment’s I is u8.

Source

pub fn with_offset_and_endidness( data: &'s [u8], initial_offset: usize, endidness: Endidness, ) -> Self

Creates a new Segment using the provided endidness and initial offset.

Note: Only available if the Segment’s I is u8.

Source

pub fn endidness(&self) -> Endidness

The endidness of the Segment.

Note: Only available if the Segment’s I is u8.

Source

pub fn next_bytes(&self, buf: &mut [u8]) -> Result<()>

Fills the provided buffer with the next n bytes, where n is the length of the buffer. This then advances the Segment::current_offset by n.

Note: Only available if the Segment’s I is u8.

Source

pub fn int_at<N: Integer>(&self, offset: usize) -> Result<N>

Gets an integer of the provided type (e.g. u8, i8, u16, i16, etcetera) at the given offset without altering the Segment::current_offset. In most cases, you should use methods like Segment::u8_at instead.

Note: Only available if the Segment’s I is u8.

Source

pub fn u8_at(&self, offset: usize) -> Result<u8>

See the documentation for Segment::int_at.

Note: Only available if the Segment’s I is u8.

Source

pub fn u16_at(&self, offset: usize) -> Result<u16>

See the documentation for Segment::int_at.

Note: Only available if the Segment’s I is u8.

Source

pub fn u32_at(&self, offset: usize) -> Result<u32>

See the documentation for Segment::int_at.

Note: Only available if the Segment’s I is u8.

Source

pub fn u64_at(&self, offset: usize) -> Result<u64>

See the documentation for Segment::int_at.

Note: Only available if the Segment’s I is u8.

Source

pub fn u128_at(&self, offset: usize) -> Result<u128>

See the documentation for Segment::int_at.

Note: Only available if the Segment’s I is u8.

Source

pub fn i8_at(&self, offset: usize) -> Result<i8>

See the documentation for Segment::int_at.

Note: Only available if the Segment’s I is u8.

Source

pub fn i16_at(&self, offset: usize) -> Result<i16>

See the documentation for Segment::int_at.

Note: Only available if the Segment’s I is u8.

Source

pub fn i32_at(&self, offset: usize) -> Result<i32>

See the documentation for Segment::int_at.

Note: Only available if the Segment’s I is u8.

Source

pub fn i64_at(&self, offset: usize) -> Result<i64>

See the documentation for Segment::int_at.

Note: Only available if the Segment’s I is u8.

Source

pub fn i128_at(&self, offset: usize) -> Result<i128>

See the documentation for Segment::int_at.

Note: Only available if the Segment’s I is u8.

Source

pub fn current_int<N: Integer>(&self) -> Result<N>

Gets an integer of the provided type (e.g. u8, i8, u16, i16, etcetera) starting at the at the Segment::current_offset without altering it. In most cases, you should use methods like Segment::current_u8 instead.

Note: Only available if the Segment’s I is u8.

Source

pub fn current_u8(&self) -> Result<u8>

See the documentation for Segment::current_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn current_u16(&self) -> Result<u16>

See the documentation for Segment::current_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn current_u32(&self) -> Result<u32>

See the documentation for Segment::current_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn current_u64(&self) -> Result<u64>

See the documentation for Segment::current_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn current_u128(&self) -> Result<u128>

See the documentation for Segment::current_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn current_i8(&self) -> Result<i8>

See the documentation for Segment::current_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn current_i16(&self) -> Result<i16>

See the documentation for Segment::current_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn current_i32(&self) -> Result<i32>

See the documentation for Segment::current_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn current_i64(&self) -> Result<i64>

See the documentation for Segment::current_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn current_i128(&self) -> Result<i128>

See the documentation for Segment::current_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn peek_int<N: Integer>(&self) -> Result<N>

Gets an integer of the provided type (e.g. u8, i8, u16, i16, etcetera) starting at the at the Segment::current_offset but without advancing the Segment::current_offset. In most cases, you should use methods like Segment::peek_u8 instead.

Note: Only available if the Segment’s I is u8.

Source

pub fn peek_u8(&self) -> Result<u8>

See the documentation for Segment::peek_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn peek_u16(&self) -> Result<u16>

See the documentation for Segment::peek_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn peek_u32(&self) -> Result<u32>

See the documentation for Segment::peek_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn peek_u64(&self) -> Result<u64>

See the documentation for Segment::peek_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn peek_u128(&self) -> Result<u128>

See the documentation for Segment::peek_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn peek_i8(&self) -> Result<i8>

See the documentation for Segment::peek_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn peek_i16(&self) -> Result<i16>

See the documentation for Segment::peek_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn peek_i32(&self) -> Result<i32>

See the documentation for Segment::peek_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn peek_i64(&self) -> Result<i64>

See the documentation for Segment::peek_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn peek_i128(&self) -> Result<i128>

See the documentation for Segment::peek_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn next_int<N: Integer>(&self) -> Result<N>

Gets an integer of the provided type (e.g. u8, i8, u16, i16, etcetera) starting at the at the Segment::current_offset and then advances the Segment::current_offset by n, where n is the number of bytes required to create the requested integer type. In most cases, you should use methods like Segment::next_u8 instead.

Note: Only available if the Segment’s I is u8.

Source

pub fn next_u8(&self) -> Result<u8>

See the documentation for Segment::next_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn next_u16(&self) -> Result<u16>

See the documentation for Segment::next_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn next_u32(&self) -> Result<u32>

See the documentation for Segment::next_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn next_u64(&self) -> Result<u64>

See the documentation for Segment::next_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn next_u128(&self) -> Result<u128>

See the documentation for Segment::next_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn next_i8(&self) -> Result<i8>

See the documentation for Segment::next_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn next_i16(&self) -> Result<i16>

See the documentation for Segment::next_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn next_i32(&self) -> Result<i32>

See the documentation for Segment::next_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn next_i64(&self) -> Result<i64>

See the documentation for Segment::next_int.

Note: Only available if the Segment’s I is u8.

Source

pub fn next_i128(&self) -> Result<i128>

See the documentation for Segment::next_int.

Note: Only available if the Segment’s I is u8.

Source§

impl<'s, I> Segment<'s, I>

Source

pub fn new(data: &'s [I]) -> Self

Source

pub fn change_initial_offset(&mut self, offset: usize)

Changes the initial offset.

Source

pub fn next_n_as_slice(&self, num_items: usize) -> Result<&[I]>

Returns a slice of the requested size containing the next n items (where n is the num_items parameter) and then advances the Segment::current_offset by that much.

Source

pub fn next_item_ref(&self) -> Result<&I>

Gets a reference to the next item and then advances the Segment::current_offset by 1

Source

pub fn next_n(&self, num_items: usize) -> Result<Segment<'_, I>>

Source

pub fn next_item_refs(&self, buf: &mut [&'s I]) -> Result<()>

Fills the provided buffer with the next n items, where n is the length of the buffer and then advances the Segment::current_offset by n.

Source

pub fn with_offset(data: &'s [I], initial_offset: usize) -> Self

Generates a new Segment using the provided slice and initial offset.

Source

pub fn initial_offset(&self) -> usize

The initial offset of the Segment. For more information, see the Offsets section of the Segment documentation (which still needs to be written…).

Source

pub fn size(&self) -> usize

The number of items initially provided to the Segment. Because a Segment’s data can’t be changed, this value will never change either.

Source

pub fn current_offset(&self) -> usize

The current offset of the Segment’s cursor.

Source

pub fn move_to(&self, offset: usize) -> Result<()>

Sets the reader’s Segment::current_offset.

Source

pub fn move_by(&self, num_items: i128) -> Result<()>

Alters the Segment::current_offset by the given amount.

Source

pub fn item_ref_at(&self, offset: usize) -> Result<&I>

Gets the item at the provided offset without altering the Segment::current_offset.

Source

pub fn current_item_ref(&self) -> Result<&I>

Source

pub fn get_remaining_as_slice(&self) -> Result<&[I]>

Gets a slice of all remaining data in the Segment and then advances the Segment::current_offset to the end of the segment.

Source

pub fn get_remaining(&self) -> Result<Self>

Source

pub fn lower_offset_limit(&self) -> usize

The lowest valid offset that can be requested.

Source

pub fn upper_offset_limit(&self) -> usize

The highest valid offset that can be requested.

Source

pub fn is_empty(&self) -> bool

Checks whether or not there is any data left, relative to the Segment::current_offset.

Source

pub fn remaining(&self) -> usize

The amount of data left, relative to the Segment::current_offset.

Source

pub fn has_more(&self) -> bool

Returns true if there is more data after the Segment::current_offset.

Source

pub fn item_refs_at<'a>( &'s self, offset: usize, buf: &mut [&'a I], ) -> Result<()>
where 's: 'a,

Fills the provided buffer with references to items, starting at the provided offset. This does not alter the Segment::current_offset.

Source

pub fn validate_offset(&self, offset: usize, size: usize) -> Result<()>

A helper method that validates an offset.

If the offset is valid, then Ok(()) will be returned. Otherwise, the appropriate Error is returned.

Source

pub fn relative_offset(&self, abs_offset: usize) -> Result<usize>

Takes an absolute offset and converts it to a relative offset, based off of the Segment::current_offset.

Source

pub fn get_n(&self, offset: usize, num_items: usize) -> Result<Segment<'_, I>>

Returns a new Segment of the requested size, starting at the provied offset. This does not alter the Segment::current_offset.

Source

pub fn get_n_as_slice(&self, offset: usize, num_items: usize) -> Result<&[I]>

Source

pub fn get_as_slice(&self, start: usize, end: usize) -> Result<&[I]>

Returns a slice of the data between the provided starting and ending offsets.

Source

pub fn segment(&self, start: usize, end: usize) -> Result<Segment<'_, I>>

Source

pub fn all_after(&self, offset: usize) -> Result<Segment<'_, I>>

Creates a new segment off all items after the provided offset (inclusive).

Source

pub fn all_before(&self, offset: usize) -> Result<Segment<'_, I>>

Creates a new segment off all items before the provided offset (exclusive).

Source§

impl<'s, I> Segment<'s, I>
where I: Default + Copy,

Source

pub fn next_n_as_array<const N: usize>(&self) -> Result<[I; N]>

Gets the next n items as an array and then advances the Segment::current_offset by the size of the array

Source§

impl<'s, I> Segment<'s, I>
where I: PartialEq,

Source

pub fn next_items_are(&self, prefix: &[I]) -> Result<bool>

Returns true if the next items are the same as the ones in the provided slice.

Source§

impl<'s, I: Clone> Segment<'s, I>

Source

pub fn items_at(&self, offset: usize, buf: &mut [I]) -> Result<()>

Fills the provided buffer with bytes, starting at the provided offset. This does not alter the Segment::current_offset.

Source

pub fn next_item(&self) -> Result<I>

Gets the current byte and then advances the cursor.

Source

pub fn next_items(&self, buf: &mut [I]) -> Result<()>

Source

pub fn item_at(&self, offset: usize) -> Result<I>

Gets the item at the provided offset without altering the Segment::current_offset.

Source

pub fn current_item(&self) -> Result<I>

Trait Implementations§

Source§

impl<'s, I> AsRef<[I]> for Segment<'s, I>

Source§

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

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

impl<'r> AsyncBufRead for Segment<'r, u8>

Source§

fn poll_fill_buf( self: Pin<&mut Self>, _: &mut Context<'_>, ) -> Poll<Result<&[u8]>>

Attempts to return the contents of the internal buffer, filling it with more data from the inner reader if it is empty. Read more
Source§

fn consume(self: Pin<&mut Self>, amount: usize)

Tells this buffer that amt bytes have been consumed from the buffer, so they should no longer be returned in calls to poll_read. Read more
Source§

impl<'r> AsyncRead for Segment<'r, u8>

Source§

fn poll_read( self: Pin<&mut Self>, _: &mut Context<'_>, buf: &mut ReadBuf<'_>, ) -> Poll<Result<()>>

Attempts to read from the AsyncRead into buf. Read more
Source§

impl<'r> AsyncSeek for Segment<'r, u8>

Source§

fn start_seek(self: Pin<&mut Self>, pos: SeekFrom) -> Result<()>

Attempts to seek to an offset, in bytes, in a stream. Read more
Source§

fn poll_complete(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<u64>>

Waits for a seek operation to complete. Read more
Source§

impl<'s, I> Borrow<[I]> for Segment<'s, I>

Source§

fn borrow(&self) -> &[I]

Immutably borrows from an owned value. Read more
Source§

impl<'s> BufRead for Segment<'s, u8>

Source§

fn fill_buf(&mut self) -> Result<&[u8]>

Returns the contents of the internal buffer, filling it with more data, via Read methods, if empty. Read more
Source§

fn consume(&mut self, amt: usize)

Marks the given amount of additional bytes from the internal buffer as having been read. Subsequent calls to read only return bytes that have not been marked as read. Read more
Source§

fn has_data_left(&mut self) -> Result<bool, Error>

🔬This is a nightly-only experimental API. (buf_read_has_data_left)
Checks if there is any data left to be read. Read more
1.0.0 · Source§

fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> Result<usize, Error>

Reads all bytes into buf until the delimiter byte or EOF is reached. Read more
1.83.0 · Source§

fn skip_until(&mut self, byte: u8) -> Result<usize, Error>

Skips all bytes until the delimiter byte or EOF is reached. Read more
1.0.0 · Source§

fn read_line(&mut self, buf: &mut String) -> Result<usize, Error>

Reads all bytes until a newline (the 0xA byte) is reached, and append them to the provided String buffer. Read more
1.0.0 · Source§

fn split(self, byte: u8) -> Split<Self>
where Self: Sized,

Returns an iterator over the contents of this reader split on the byte byte. Read more
1.0.0 · Source§

fn lines(self) -> Lines<Self>
where Self: Sized,

Returns an iterator over the lines of this reader. Read more
Source§

impl<'s, I> Clone for Segment<'s, I>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'s, I> Index<Range<usize>> for Segment<'s, I>

Source§

type Output = [I]

The returned type after indexing.
Source§

fn index(&self, idx: Range<usize>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'s, I> Index<RangeFrom<usize>> for Segment<'s, I>

Source§

type Output = [I]

The returned type after indexing.
Source§

fn index(&self, idx: RangeFrom<usize>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'s, I> Index<RangeFull> for Segment<'s, I>

Source§

type Output = [I]

The returned type after indexing.
Source§

fn index(&self, idx: RangeFull) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'s, I> Index<RangeInclusive<usize>> for Segment<'s, I>

Source§

type Output = [I]

The returned type after indexing.
Source§

fn index(&self, idx: RangeInclusive<usize>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'s, I> Index<RangeTo<usize>> for Segment<'s, I>

Source§

type Output = [I]

The returned type after indexing.
Source§

fn index(&self, idx: RangeTo<usize>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'s, I> Index<RangeToInclusive<usize>> for Segment<'s, I>

Source§

type Output = [I]

The returned type after indexing.
Source§

fn index(&self, idx: RangeToInclusive<usize>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'s, I> Index<usize> for Segment<'s, I>

Source§

type Output = I

The returned type after indexing.
Source§

fn index(&self, idx: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'s> Read for Segment<'s, u8>

Source§

fn read(&mut self, buf: &mut [u8]) -> Result<usize>

Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
1.36.0 · Source§

fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>

Like read, except that it reads into a slice of buffers. Read more
Source§

fn is_read_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Reader has an efficient read_vectored implementation. Read more
1.0.0 · Source§

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>

Reads all bytes until EOF in this source, placing them into buf. Read more
1.0.0 · Source§

fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>

Reads all bytes until EOF in this source, appending them to buf. Read more
1.6.0 · Source§

fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>

Reads the exact number of bytes required to fill buf. Read more
Source§

fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>

🔬This is a nightly-only experimental API. (read_buf)
Pull some bytes from this source into the specified buffer. Read more
Source§

fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>

🔬This is a nightly-only experimental API. (read_buf)
Reads the exact number of bytes required to fill cursor. Read more
1.0.0 · Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adaptor for this instance of Read. Read more
1.0.0 · Source§

fn bytes(self) -> Bytes<Self>
where Self: Sized,

Transforms this Read instance to an Iterator over its bytes. Read more
1.0.0 · Source§

fn chain<R>(self, next: R) -> Chain<Self, R>
where R: Read, Self: Sized,

Creates an adapter which will chain this stream with another. Read more
1.0.0 · Source§

fn take(self, limit: u64) -> Take<Self>
where Self: Sized,

Creates an adapter which will read at most limit bytes from it. Read more
Source§

impl<'s> Seek for Segment<'s, u8>

Source§

fn seek(&mut self, pos: SeekFrom) -> Result<u64>

Seek to an offset, in bytes, in a stream. Read more
1.55.0 · Source§

fn rewind(&mut self) -> Result<(), Error>

Rewind to the beginning of a stream. Read more
Source§

fn stream_len(&mut self) -> Result<u64, Error>

🔬This is a nightly-only experimental API. (seek_stream_len)
Returns the length of this stream (in bytes). Read more
1.51.0 · Source§

fn stream_position(&mut self) -> Result<u64, Error>

Returns the current seek position from the start of the stream. Read more
1.80.0 · Source§

fn seek_relative(&mut self, offset: i64) -> Result<(), Error>

Seeks relative to the current position. Read more
Source§

impl<'s, I, const N: usize> TryFrom<&Segment<'s, I>> for [I; N]
where I: Default + Copy,

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(segment: &Segment<'s, I>) -> Result<Self>

Performs the conversion.
Source§

impl<'s, const N: usize> TryFrom<&Segment<'s, u8>> for [i128; N]

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(segment: &Segment<'s, u8>) -> Result<Self>

Performs the conversion.
Source§

impl<'s, const N: usize> TryFrom<&Segment<'s, u8>> for [i16; N]

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(segment: &Segment<'s, u8>) -> Result<Self>

Performs the conversion.
Source§

impl<'s, const N: usize> TryFrom<&Segment<'s, u8>> for [i32; N]

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(segment: &Segment<'s, u8>) -> Result<Self>

Performs the conversion.
Source§

impl<'s, const N: usize> TryFrom<&Segment<'s, u8>> for [i64; N]

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(segment: &Segment<'s, u8>) -> Result<Self>

Performs the conversion.
Source§

impl<'s, const N: usize> TryFrom<&Segment<'s, u8>> for [i8; N]

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(segment: &Segment<'s, u8>) -> Result<Self>

Performs the conversion.
Source§

impl<'s, const N: usize> TryFrom<&Segment<'s, u8>> for [u128; N]

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(segment: &Segment<'s, u8>) -> Result<Self>

Performs the conversion.
Source§

impl<'s, const N: usize> TryFrom<&Segment<'s, u8>> for [u16; N]

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(segment: &Segment<'s, u8>) -> Result<Self>

Performs the conversion.
Source§

impl<'s, const N: usize> TryFrom<&Segment<'s, u8>> for [u32; N]

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(segment: &Segment<'s, u8>) -> Result<Self>

Performs the conversion.
Source§

impl<'s, const N: usize> TryFrom<&Segment<'s, u8>> for [u64; N]

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(segment: &Segment<'s, u8>) -> Result<Self>

Performs the conversion.
Source§

impl<'s> TryFrom<&Segment<'s, u8>> for ()

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(_: &Segment<'s, u8>) -> Result<Self>

Performs the conversion.
Source§

impl<'s> TryFrom<&Segment<'s, u8>> for i128

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(segment: &Segment<'s, u8>) -> Result<Self>

Performs the conversion.
Source§

impl<'s> TryFrom<&Segment<'s, u8>> for i16

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(segment: &Segment<'s, u8>) -> Result<Self>

Performs the conversion.
Source§

impl<'s> TryFrom<&Segment<'s, u8>> for i32

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(segment: &Segment<'s, u8>) -> Result<Self>

Performs the conversion.
Source§

impl<'s> TryFrom<&Segment<'s, u8>> for i64

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(segment: &Segment<'s, u8>) -> Result<Self>

Performs the conversion.
Source§

impl<'s> TryFrom<&Segment<'s, u8>> for i8

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(segment: &Segment<'s, u8>) -> Result<Self>

Performs the conversion.
Source§

impl<'s> TryFrom<&Segment<'s, u8>> for u128

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(segment: &Segment<'s, u8>) -> Result<Self>

Performs the conversion.
Source§

impl<'s> TryFrom<&Segment<'s, u8>> for u16

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(segment: &Segment<'s, u8>) -> Result<Self>

Performs the conversion.
Source§

impl<'s> TryFrom<&Segment<'s, u8>> for u32

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(segment: &Segment<'s, u8>) -> Result<Self>

Performs the conversion.
Source§

impl<'s> TryFrom<&Segment<'s, u8>> for u64

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(segment: &Segment<'s, u8>) -> Result<Self>

Performs the conversion.
Source§

impl<'s> TryFrom<&Segment<'s, u8>> for u8

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(segment: &Segment<'s, u8>) -> Result<Self>

Performs the conversion.

Auto Trait Implementations§

§

impl<'s, I> !Freeze for Segment<'s, I>

§

impl<'s, I> RefUnwindSafe for Segment<'s, I>
where I: RefUnwindSafe,

§

impl<'s, I> Send for Segment<'s, I>
where I: Sync,

§

impl<'s, I> Sync for Segment<'s, I>
where I: Sync,

§

impl<'s, I> Unpin for Segment<'s, I>

§

impl<'s, I> UnwindSafe for Segment<'s, I>
where I: RefUnwindSafe,

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<R> AsyncBufReadExt for R
where R: AsyncBufRead + ?Sized,

Source§

fn read_until<'a>( &'a mut self, byte: u8, buf: &'a mut Vec<u8>, ) -> ReadUntil<'a, Self>
where Self: Unpin,

Reads all bytes into buf until the delimiter byte or EOF is reached. Read more
Source§

fn read_line<'a>(&'a mut self, buf: &'a mut String) -> ReadLine<'a, Self>
where Self: Unpin,

Reads all bytes until a newline (the 0xA byte) is reached, and append them to the provided buffer. Read more
Source§

fn split(self, byte: u8) -> Split<Self>
where Self: Sized + Unpin,

Returns a stream of the contents of this reader split on the byte byte. Read more
Source§

fn fill_buf(&mut self) -> FillBuf<'_, Self>
where Self: Unpin,

Returns the contents of the internal buffer, filling it with more data from the inner reader if it is empty. Read more
Source§

fn consume(&mut self, amt: usize)
where Self: Unpin,

Tells this buffer that amt bytes have been consumed from the buffer, so they should no longer be returned in calls to read. Read more
Source§

fn lines(self) -> Lines<Self>
where Self: Sized,

Returns a stream over the lines of this reader. This method is the async equivalent to BufRead::lines. Read more
Source§

impl<R> AsyncReadExt for R
where R: AsyncRead + ?Sized,

Source§

fn chain<R>(self, next: R) -> Chain<Self, R>
where Self: Sized, R: AsyncRead,

Creates a new AsyncRead instance that chains this stream with next. Read more
Source§

fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self>
where Self: Unpin,

Pulls some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Source§

fn read_buf<'a, B>(&'a mut self, buf: &'a mut B) -> ReadBuf<'a, Self, B>
where Self: Unpin, B: BufMut + ?Sized,

Pulls some bytes from this source into the specified buffer, advancing the buffer’s internal cursor. Read more
Source§

fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self>
where Self: Unpin,

Reads the exact number of bytes required to fill buf. Read more
Source§

fn read_u8(&mut self) -> ReadU8<&mut Self>
where Self: Unpin,

Reads an unsigned 8 bit integer from the underlying reader. Read more
Source§

fn read_i8(&mut self) -> ReadI8<&mut Self>
where Self: Unpin,

Reads a signed 8 bit integer from the underlying reader. Read more
Source§

fn read_u16(&mut self) -> ReadU16<&mut Self>
where Self: Unpin,

Reads an unsigned 16-bit integer in big-endian order from the underlying reader. Read more
Source§

fn read_i16(&mut self) -> ReadI16<&mut Self>
where Self: Unpin,

Reads a signed 16-bit integer in big-endian order from the underlying reader. Read more
Source§

fn read_u32(&mut self) -> ReadU32<&mut Self>
where Self: Unpin,

Reads an unsigned 32-bit integer in big-endian order from the underlying reader. Read more
Source§

fn read_i32(&mut self) -> ReadI32<&mut Self>
where Self: Unpin,

Reads a signed 32-bit integer in big-endian order from the underlying reader. Read more
Source§

fn read_u64(&mut self) -> ReadU64<&mut Self>
where Self: Unpin,

Reads an unsigned 64-bit integer in big-endian order from the underlying reader. Read more
Source§

fn read_i64(&mut self) -> ReadI64<&mut Self>
where Self: Unpin,

Reads an signed 64-bit integer in big-endian order from the underlying reader. Read more
Source§

fn read_u128(&mut self) -> ReadU128<&mut Self>
where Self: Unpin,

Reads an unsigned 128-bit integer in big-endian order from the underlying reader. Read more
Source§

fn read_i128(&mut self) -> ReadI128<&mut Self>
where Self: Unpin,

Reads an signed 128-bit integer in big-endian order from the underlying reader. Read more
Source§

fn read_f32(&mut self) -> ReadF32<&mut Self>
where Self: Unpin,

Reads an 32-bit floating point type in big-endian order from the underlying reader. Read more
Source§

fn read_f64(&mut self) -> ReadF64<&mut Self>
where Self: Unpin,

Reads an 64-bit floating point type in big-endian order from the underlying reader. Read more
Source§

fn read_u16_le(&mut self) -> ReadU16Le<&mut Self>
where Self: Unpin,

Reads an unsigned 16-bit integer in little-endian order from the underlying reader. Read more
Source§

fn read_i16_le(&mut self) -> ReadI16Le<&mut Self>
where Self: Unpin,

Reads a signed 16-bit integer in little-endian order from the underlying reader. Read more
Source§

fn read_u32_le(&mut self) -> ReadU32Le<&mut Self>
where Self: Unpin,

Reads an unsigned 32-bit integer in little-endian order from the underlying reader. Read more
Source§

fn read_i32_le(&mut self) -> ReadI32Le<&mut Self>
where Self: Unpin,

Reads a signed 32-bit integer in little-endian order from the underlying reader. Read more
Source§

fn read_u64_le(&mut self) -> ReadU64Le<&mut Self>
where Self: Unpin,

Reads an unsigned 64-bit integer in little-endian order from the underlying reader. Read more
Source§

fn read_i64_le(&mut self) -> ReadI64Le<&mut Self>
where Self: Unpin,

Reads an signed 64-bit integer in little-endian order from the underlying reader. Read more
Source§

fn read_u128_le(&mut self) -> ReadU128Le<&mut Self>
where Self: Unpin,

Reads an unsigned 128-bit integer in little-endian order from the underlying reader. Read more
Source§

fn read_i128_le(&mut self) -> ReadI128Le<&mut Self>
where Self: Unpin,

Reads an signed 128-bit integer in little-endian order from the underlying reader. Read more
Source§

fn read_f32_le(&mut self) -> ReadF32Le<&mut Self>
where Self: Unpin,

Reads an 32-bit floating point type in little-endian order from the underlying reader. Read more
Source§

fn read_f64_le(&mut self) -> ReadF64Le<&mut Self>
where Self: Unpin,

Reads an 64-bit floating point type in little-endian order from the underlying reader. Read more
Source§

fn read_to_end<'a>(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self>
where Self: Unpin,

Reads all bytes until EOF in this source, placing them into buf. Read more
Source§

fn read_to_string<'a>( &'a mut self, dst: &'a mut String, ) -> ReadToString<'a, Self>
where Self: Unpin,

Reads all bytes until EOF in this source, appending them to buf. Read more
Source§

fn take(self, limit: u64) -> Take<Self>
where Self: Sized,

Creates an adaptor which reads at most limit bytes from it. Read more
Source§

impl<S> AsyncSeekExt for S
where S: AsyncSeek + ?Sized,

Source§

fn seek(&mut self, pos: SeekFrom) -> Seek<'_, Self>
where Self: Unpin,

Creates a future which will seek an IO object, and then yield the new position in the object and the object itself. Read more
Source§

fn rewind(&mut self) -> Seek<'_, Self>
where Self: Unpin,

Creates a future which will rewind to the beginning of the stream. Read more
Source§

fn stream_position(&mut self) -> Seek<'_, Self>
where Self: Unpin,

Creates a future which will return the current seek position from the start of the stream. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.