reproto_derive/format.rs
1use core;
2use core::errors::Result;
3use sir::Sir;
4use std::fmt;
5
6///
7/// Decoder to use.
8pub trait Format: fmt::Debug {
9 fn decode(&self, object: &core::Source) -> Result<Sir>;
10}
11
12/// Object accessor
13pub trait Object {
14 type Value;
15
16 /// Get the value of the given key.
17 fn get(&self, key: &str) -> Option<&Self::Value>;
18}
19
20pub trait Value {
21 /// Attempt to convert the current value into an Object.
22 fn as_object(&self) -> Option<&Object<Value = Self>>;
23
24 /// Attempt to convert the current value into a String.
25 fn as_str(&self) -> Option<&str>;
26}