pub trait Policy {
type Ret;
type Set;
type Inv<'a>;
type Ser;
type Error: Into<Error>;
// Required method
fn parse(
&mut self,
set: &mut Self::Set,
inv: &mut Self::Inv<'_>,
ser: &mut Self::Ser,
args: Rc<Args>
) -> Result<Self::Ret, Self::Error>;
}
Expand description
Policy
doing real parsing work.
§Example
ⓘ
#[derive(Debug)]
pub struct EmptyPolicy<Set, Ser>(PhantomData<(Set, Ser)>);
// An empty policy do nothing.
impl<S: Set, Ser> Policy for EmptyPolicy<S, Ser> {
type Ret = bool;
type Set = S;
type Inv<'a> = Invoker<'a, S, Ser>;
type Ser = Ser;
type Error = Error;
fn parse<'a>(
&mut self,
_: &mut Self::Set,
_: &mut Self::Inv<'a>,
_: &mut Self::Ser,
_: ARef<Args>,
) -> Result<bool, Error> {
// ... parsing logical code
Ok(true)
}
}
Required Associated Types§
Required Methods§
fn parse( &mut self, set: &mut Self::Set, inv: &mut Self::Inv<'_>, ser: &mut Self::Ser, args: Rc<Args> ) -> Result<Self::Ret, Self::Error>
Object Safety§
This trait is not object safe.