Enum boxcars::HeaderProp [−][src]
pub enum HeaderProp { Array(Vec<Vec<(String, HeaderProp)>>), Bool(bool), Byte { kind: String, value: Option<String>, }, Float(f32), Int(i32), Name(String), QWord(u64), Str(String), }
Expand description
All the interesting data are stored as properties in the header, properties such as:
- When and who scored a goal
- Player stats (goals, assists, score, etc).
- Date and level played on
A property can be a number, string, or a more complex object such as an array containing additional properties.
Variants
Tuple Fields of Bool
0: bool
Tuple Fields of Float
0: f32
Tuple Fields of Int
0: i32
Tuple Fields of Name
0: String
Tuple Fields of QWord
0: u64
Tuple Fields of Str
0: String
Implementations
If the HeaderProp
is an array of properties, returns the array
let v = HeaderProp::Array(vec![ vec![("abc".to_string(), HeaderProp::QWord(10))] ]); assert_eq!(v.as_array().unwrap().len(), 1); assert_eq!(v.as_array().unwrap()[0][0].1.as_array(), None);
If the HeaderProp
is a boolean, returns the value
let v = HeaderProp::Bool(true); let b = HeaderProp::QWord(10); assert_eq!(v.as_bool(), Some(true)); assert_eq!(b.as_bool(), None);
If the HeaderProp
is a float, returns the value
let v = HeaderProp::Float(2.50); let b = HeaderProp::QWord(10); assert_eq!(v.as_float(), Some(2.50)); assert_eq!(b.as_float(), None);
If the HeaderProp
is a QWord, returns the value
let v = HeaderProp::QWord(250); let b = HeaderProp::Bool(true); assert_eq!(v.as_u64(), Some(250)); assert_eq!(b.as_u64(), None);
If the HeaderProp
is an int, returns the value
let v = HeaderProp::Int(-250); let b = HeaderProp::Bool(true); assert_eq!(v.as_i32(), Some(-250)); assert_eq!(b.as_i32(), None);
If the HeaderProp
is an string, returns the value
let v = HeaderProp::Name("abc".to_string()); let x = HeaderProp::Str("def".to_string()); let b = HeaderProp::QWord(10); assert_eq!(v.as_string(), Some("abc")); assert_eq!(x.as_string(), Some("def")); assert_eq!(b.as_i32(), None);
Trait Implementations
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
By default serde will generate a serialization method that writes out the enum as well as the
enum value. Since header values are self describing in JSON, we do not need to serialize the
enum type. This is slightly lossy as in the serialized format it will be ambiguous if a value
is a Name
or Str
, as well as Byte
, Float
, Int
, or QWord
.
Auto Trait Implementations
impl RefUnwindSafe for HeaderProp
impl Send for HeaderProp
impl Sync for HeaderProp
impl Unpin for HeaderProp
impl UnwindSafe for HeaderProp
Blanket Implementations
Mutably borrows from an owned value. Read more