Struct Window

Source
pub struct Window<B> { /* private fields */ }
Expand description

A pattern which represents a window of a byte oriented buffer.

Implementations§

Source§

impl<B: AsRef<[u8]> + AsMut<[u8]>> Window<B>

Source

pub fn new(buf: B) -> Self

Makes new window.

Source§

impl<B: AsRef<[u8]>> Window<B>

Source

pub fn new_ref(buf: B) -> Self

Makes new window for an immutable buffer.

Source

pub fn set_end(self, end: usize) -> Self

Sets end position of the window.

Source§

impl<B: AsMut<[u8]>> Window<B>

Source

pub fn new_mut(buf: B) -> Self

Makes new window for an mutable buffer.

Source§

impl<B> Window<B>

Source

pub fn inner_ref(&self) -> &B

Returns the immutable reference of the internal buffer.

Source

pub fn inner_mut(&mut self) -> &mut B

Returns the mutable reference of the internal buffer.

Source

pub fn into_inner(self) -> B

Converts to the internal buffer.

Source

pub fn start(&self) -> usize

Returns the start point of the window.

Source

pub fn end(&self) -> usize

Returns the end point of the window.

Source

pub fn skip(self, size: usize) -> Self

Converts to new window which skipped first size bytes of self.

Source

pub fn take(self, size: usize) -> Self

Converts to new window which took first size bytes of self.

Source

pub fn set_start(self, start: usize) -> Self

Sets start position of the window.

Trait Implementations§

Source§

impl<B> AllowPartial for Window<B>

Source§

fn allow_partial(self) -> PartialBuf<Self>

Indicates that this pattern is partially evaluable.
Source§

impl<B: AsMut<[u8]>> AsMut<[u8]> for Window<B>

Source§

fn as_mut(&mut self) -> &mut [u8]

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

impl<B: AsRef<[u8]>> AsRef<[u8]> for Window<B>

Source§

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

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

impl<R: Read, B: AsMut<[u8]>> AsyncMatch<PatternReader<R>> for Window<B>

Source§

type Future = ReadBuf<R, Window<B>>

The future type which will produce a value Self::Value by matching this pattern and a matcher M.
Source§

fn async_match(self, matcher: PatternReader<R>) -> Self::Future

Creates a future which will produce a Self::Value by matching this pattern and the matcher.
Source§

fn into_stream(self, matcher: M) -> MatchStream<M, Self>
where Self: Clone,

Consumes this pattern and the matcher, returning a stream which will produce a sequence of matched values. Read more
Source§

impl<W: Write, B: AsRef<[u8]>> AsyncMatch<PatternWriter<W>> for Window<B>

Source§

type Future = WriteBuf<W, Window<B>>

The future type which will produce a value Self::Value by matching this pattern and a matcher M.
Source§

fn async_match(self, matcher: PatternWriter<W>) -> Self::Future

Creates a future which will produce a Self::Value by matching this pattern and the matcher.
Source§

fn into_stream(self, matcher: M) -> MatchStream<M, Self>
where Self: Clone,

Consumes this pattern and the matcher, returning a stream which will produce a sequence of matched values. Read more
Source§

impl<B: Clone> Clone for Window<B>

Source§

fn clone(&self) -> Window<B>

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<B: Debug> Debug for Window<B>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T> ExternalSize for Window<T>

Source§

fn external_size(&self) -> usize

Calculates external byte size issued when an I/O operation is performed on this.
Source§

impl<B> Pattern for Window<B>

Source§

type Value = Window<B>

The value type associated to the pattern.
Source§

fn then<F, P, E>(self, f: F) -> Then<Self, F, E>
where F: FnOnce(Result<Self::Value, E>) -> P,

Takes a closure which maps a Result<Self::Value> to a pattern, and creates a pattern which calls that closure on the evaluation result of self.
Source§

fn and_then<F, P>(self, f: F) -> AndThen<Self, F>
where F: FnOnce(Self::Value) -> P,

Takes a closure which maps a value to a pattern, and creates a pattern which calls that closure if the evaluation of self was succeeded.
Source§

fn or_else<F, P, E>(self, f: F) -> OrElse<Self, F, E>
where F: FnOnce(E) -> P,

Takes a closure which maps an error to a pattern, and creates a pattern which calls that closure if the evaluation of self failed.
Source§

fn or<P>(self, other: P) -> Or<Self, P>
where P: Pattern<Value = Self::Value>,

Takes a pattern other which will be used if the evaluation of self is failed.
Source§

fn map<F, T>(self, f: F) -> Map<Self, F>
where F: FnOnce(Self::Value) -> T,

Takes a closure which maps a value to another value, and creates a pattern which calls that closure on the evaluated value of self.
Source§

fn chain<P>(self, other: P) -> Chain<Self, P>
where P: Pattern,

Takes two patterns and creates a new pattern over both in sequence. Read more
Source§

fn repeat(self) -> Repeat<Self>
where Self: Clone,

Creates Repeat pattern to represent an infinite stream of this pattern.
Source§

fn boxed<M: Matcher>(self) -> BoxPattern<M, Self::Value>
where Self: AsyncMatch<M> + 'static, Self::Future: Send + 'static,

Returnes a boxed pattern to match with a matcher M.

Auto Trait Implementations§

§

impl<B> Freeze for Window<B>
where B: Freeze,

§

impl<B> RefUnwindSafe for Window<B>
where B: RefUnwindSafe,

§

impl<B> Send for Window<B>
where B: Send,

§

impl<B> Sync for Window<B>
where B: Sync,

§

impl<B> Unpin for Window<B>
where B: Unpin,

§

impl<B> UnwindSafe for Window<B>
where B: UnwindSafe,

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> 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<R, T> ReadFrom<R> for T
where R: Read, T: AsyncMatch<PatternReader<R>>,

Source§

fn read_from(self, reader: R) -> ReadPattern<Self, R>

Creates a future instance to read a value of the pattern from reader. Read more
Source§

fn sync_read_from(self, reader: R) -> Result<Self::Value>

Synchronous version of the ReadFrom::read_from method.
Source§

fn into_stream(self, reader: R) -> ReadStream<R, Self>
where Self: Clone,

Consumes this pattern and the reader, returning a stream which will produce a sequence of read values. Read more
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.
Source§

impl<W, T> WriteInto<W> for T
where W: Write, T: AsyncMatch<PatternWriter<W>>,

Source§

fn write_into(self, writer: W) -> WritePattern<Self, W>

Creates a future instance to write a value of the pattern to writer. Read more
Source§

fn sync_write_into(self, writer: W) -> Result<Self::Value>

Synchronous version of the WriteInto::write_into method.