Trait handy_io::pattern::Pattern
[−]
[src]
pub trait Pattern: Sized { type Value; fn then<F, P>(self, f: F) -> Then<Self, F>
where
F: FnOnce(Result<Self::Value>) -> P, { ... } fn and_then<F, P>(self, f: F) -> AndThen<Self, F>
where
F: FnOnce(Self::Value) -> P, { ... } fn or_else<F, P>(self, f: F) -> OrElse<Self, F>
where
F: FnOnce(Error) -> P, { ... } fn map<F, T>(self, f: F) -> Map<Self, F>
where
F: FnOnce(Self::Value) -> T, { ... } fn chain<P>(self, other: P) -> Chain<Self, P>
where
P: Pattern, { ... } fn repeat(self) -> Repeat<Self>
where
Self: Clone, { ... } }
Pattern.
Associated Types
type Value
The value type associated to the pattern.
Provided Methods
fn then<F, P>(self, f: F) -> Then<Self, F> where
F: FnOnce(Result<Self::Value>) -> P,
F: FnOnce(Result<Self::Value>) -> 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
.
fn and_then<F, P>(self, f: F) -> AndThen<Self, F> where
F: FnOnce(Self::Value) -> P,
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.
fn or_else<F, P>(self, f: F) -> OrElse<Self, F> where
F: FnOnce(Error) -> P,
F: FnOnce(Error) -> 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.
fn map<F, T>(self, f: F) -> Map<Self, F> where
F: FnOnce(Self::Value) -> T,
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
.
fn chain<P>(self, other: P) -> Chain<Self, P> where
P: Pattern,
P: Pattern,
Takes two patterns and creates a new pattern over both in sequence.
In generally, using the tuple pattern (self, P)
is more convenient way to
achieve the same effect.
fn repeat(self) -> Repeat<Self> where
Self: Clone,
Self: Clone,
Creates Repeat
pattern to represent an infinite stream of this pattern.
Implementors
impl<R, T> Pattern for BoxReadFrom<R, T>
impl<W, T> Pattern for BoxWriteTo<W, T>
impl Pattern for U8
impl Pattern for U16
impl Pattern for handy_io::pattern::read::U24
impl Pattern for U32
impl Pattern for handy_io::pattern::read::U40
impl Pattern for handy_io::pattern::read::U48
impl Pattern for handy_io::pattern::read::U56
impl Pattern for U64
impl Pattern for I8
impl Pattern for I16
impl Pattern for handy_io::pattern::read::I24
impl Pattern for I32
impl Pattern for handy_io::pattern::read::I40
impl Pattern for handy_io::pattern::read::I48
impl Pattern for handy_io::pattern::read::I56
impl Pattern for I64
impl Pattern for F32
impl Pattern for F64
impl Pattern for Eos
impl<F, T> Pattern for Until<F, T>
impl Pattern for Flush
impl Pattern for u8
impl Pattern for i8
impl Pattern for u16
impl Pattern for i16
impl Pattern for u32
impl Pattern for i32
impl Pattern for u64
impl Pattern for i64
impl Pattern for handy_io::pattern::write::U24
impl Pattern for handy_io::pattern::write::I24
impl Pattern for handy_io::pattern::write::U40
impl Pattern for handy_io::pattern::write::I40
impl Pattern for handy_io::pattern::write::U48
impl Pattern for handy_io::pattern::write::I48
impl Pattern for handy_io::pattern::write::U56
impl Pattern for handy_io::pattern::write::I56
impl<P0, P1, F> Pattern for Then<P0, F> where
P0: Pattern,
P1: Pattern,
F: FnOnce(Result<P0::Value>) -> P1,impl<P0, P1, F> Pattern for AndThen<P0, F> where
P0: Pattern,
P1: Pattern,
F: FnOnce(P0::Value) -> P1,impl<P0, P1, F> Pattern for OrElse<P0, F> where
P0: Pattern,
P1: Pattern<Value = P0::Value>,
F: FnOnce(Error) -> P1,impl<P, F, T> Pattern for Map<P, F> where
P: Pattern,
F: FnOnce(P::Value) -> T,impl<P0, P1> Pattern for Chain<P0, P1> where
P0: Pattern,
P1: Pattern,impl<I, P, F, T> Pattern for IterFold<I, F, T> where
I: Iterator<Item = P>,
P: Pattern,
F: Fn(T, P::Value) -> T,impl<T> Pattern for LE<T> where
T: Endian + Pattern,impl<T> Pattern for BE<T> where
T: Endian + Pattern,impl<B> Pattern for PartialBuf<B>
impl<I, P> Pattern for Iter<I> where
I: Iterator<Item = P>,
P: Pattern,impl<P> Pattern for Option<P> where
P: Pattern,impl<T, E> Pattern for Result<T, E>
impl Pattern for ()
impl<P0: Pattern, P1: Pattern> Pattern for (P0, P1)
impl<P0: Pattern, P1: Pattern, P2: Pattern> Pattern for (P0, P1, P2)
impl<P0: Pattern, P1: Pattern, P2: Pattern, P3: Pattern> Pattern for (P0, P1, P2, P3)
impl<P0: Pattern, P1: Pattern, P2: Pattern, P3: Pattern, P4: Pattern> Pattern for (P0, P1, P2, P3, P4)
impl<P0: Pattern, P1: Pattern, P2: Pattern, P3: Pattern, P4: Pattern, P5: Pattern> Pattern for (P0, P1, P2, P3, P4, P5)
impl<P0: Pattern, P1: Pattern, P2: Pattern, P3: Pattern, P4: Pattern, P5: Pattern, P6: Pattern> Pattern for (P0, P1, P2, P3, P4, P5, P6)
impl<P0: Pattern, P1: Pattern, P2: Pattern, P3: Pattern, P4: Pattern, P5: Pattern, P6: Pattern, P7: Pattern> Pattern for (P0, P1, P2, P3, P4, P5, P6, P7)
impl<P0: Pattern, P1: Pattern, P2: Pattern, P3: Pattern, P4: Pattern, P5: Pattern, P6: Pattern, P7: Pattern, P8: Pattern> Pattern for (P0, P1, P2, P3, P4, P5, P6, P7, P8)
impl<P0: Pattern, P1: Pattern, P2: Pattern, P3: Pattern, P4: Pattern, P5: Pattern, P6: Pattern, P7: Pattern, P8: Pattern, P9: Pattern> Pattern for (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9)
impl<A, B, C, D, E, F, G, H> Pattern for Branch<A, B, C, D, E, F, G, H> where
A: Pattern,
B: Pattern<Value = A::Value>,
C: Pattern<Value = A::Value>,
D: Pattern<Value = A::Value>,
E: Pattern<Value = A::Value>,
F: Pattern<Value = A::Value>,
G: Pattern<Value = A::Value>,
H: Pattern<Value = A::Value>,impl Pattern for Vec<u8>
impl Pattern for String
impl<B> Pattern for Buf<B>
impl<B> Pattern for Window<B>