Trait foxbox_taxonomy::parse::Parser
[−]
[src]
pub trait Parser<T: Sized> { fn description() -> String; fn parse(path: Path, source: &mut JSON) -> Result<T, ParseError>; fn from_str(source: &str) -> Result<T, ParseError> { ... } fn take(path: Path, source: &mut JSON, field_name: &str) -> Result<T, ParseError> { ... } fn take_opt(path: Path, source: &mut JSON, field_name: &str) -> Option<Result<T, ParseError>> { ... } fn take_vec_opt(path: Path, source: &mut JSON, field_name: &str) -> Option<Result<Vec<T>, ParseError>> { ... } fn take_vec(path: Path, source: &mut JSON, field_name: &str) -> Result<Vec<T>, ParseError> { ... } }
An object that knows how to parse values from JSON into type T.
The JSON object is expected to be consumed along the way. A successful parse will typically leave an empty JSON object.
Required Methods
fn description() -> String
fn parse(path: Path, source: &mut JSON) -> Result<T, ParseError>
Parse a single value from JSON, consuming as much as necessary from JSON.
Provided Methods
fn from_str(source: &str) -> Result<T, ParseError>
fn take(path: Path, source: &mut JSON, field_name: &str) -> Result<T, ParseError>
Parse a field from JSON, consuming it.
fn take_opt(path: Path, source: &mut JSON, field_name: &str) -> Option<Result<T, ParseError>>
Parse a field from JSON, consuming it.
fn take_vec_opt(path: Path, source: &mut JSON, field_name: &str) -> Option<Result<Vec<T>, ParseError>>
Parse a field containing an array from JSON, consuming the field.
fn take_vec(path: Path, source: &mut JSON, field_name: &str) -> Result<Vec<T>, ParseError>
Implementors
impl Parser<ChannelKind> for ChannelKind
impl<K> Parser<Targetted<K, Value>> for Targetted<K, Value> where K: Parser<K> + Clone
impl<K> Parser<Targetted<K, Exactly<Range>>> for Targetted<K, Exactly<Range>> where K: Parser<K> + Clone
impl Parser<f64> for f64
impl Parser<bool> for bool
impl Parser<u8> for u8
impl<T> Parser<Vec<T>> for Vec<T> where T: Parser<T>
impl Parser<String> for String
impl<T> Parser<Arc<T>> for Arc<T> where T: Parser<T>
impl Parser<ServiceSelector> for ServiceSelector
impl Parser<GetterSelector> for GetterSelector
impl Parser<SetterSelector> for SetterSelector
impl Parser<Type> for Type
impl Parser<OnOff> for OnOff
impl Parser<OpenClosed> for OpenClosed
impl Parser<Temperature> for Temperature
impl Parser<Color> for Color
impl Parser<ThinkerbellRule> for ThinkerbellRule
impl Parser<Json> for Json
impl<T> Parser<ExtValue<T>> for ExtValue<T> where T: Debug + Clone + PartialEq + PartialOrd + Serialize + Deserialize + Parser<T>
impl Parser<Binary> for Binary
impl Parser<Value> for Value
impl Parser<TimeStamp> for TimeStamp
impl Parser<Range> for Range
impl Parser<Duration> for Duration
impl<T> Parser<Exactly<T>> for Exactly<T> where T: Parser<T>
impl<T> Parser<Id<T>> for Id<T>