Struct foxbox_taxonomy::util::Id [] [src]

pub struct Id<T> {
    // some fields omitted
}

A unique id for values of a given kind.

Performance

This data structure is tuned for specific use cases and should be used accordingly.

(De)serialization

Serialized values of this type are represented by plain strings.

extern crate serde;
extern crate serde_json;
extern crate foxbox_taxonomy;

#[derive(Debug)]
struct UniqueId;

let my_id = foxbox_taxonomy::util::Id::<UniqueId>::new("Unique Identifier");

assert_eq!(my_id.to_string(), "Unique Identifier");

let my_serialized_id = serde_json::to_string(&my_id).unwrap();
assert_eq!(my_serialized_id, "\"Unique Identifier\"");

let my_deserialized_id: foxbox_taxonomy::util::Id<UniqueId> =
    serde_json::from_str("\"Unique Identifier\"").unwrap();
assert_eq!(my_deserialized_id, my_id);

Methods

impl<T> Id<T>

fn new(id: &str) -> Self

fn as_atom(&self) -> &Atom

Trait Implementations

impl<T> Display for Id<T>

fn fmt(&self, f: &mut Formatter) -> Result

impl<T> PartialEq for Id<T>

fn eq(&self, other: &Self) -> bool

1.0.0fn ne(&self, other: &Rhs) -> bool

impl<T> Eq for Id<T>

impl<T> Hash for Id<T>

fn hash<H>(&self, state: &mut H) where H: Hasher

1.3.0fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher

impl<T> Serialize for Id<T>

fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error> where S: Serializer

impl<T> Parser<Id<T>> for Id<T>

fn description() -> String

fn parse(path: Path, source: &mut JSON) -> Result<Self, 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>

impl<T> ToJSON for Id<T>

fn to_json(&self, parts: &mut BinaryParts) -> JSON

impl<T> Deserialize for Id<T>

fn deserialize<D>(deserializer: &mut D) -> Result<Self, D::Error> where D: Deserializer

Derived Implementations

impl<T: Clone> Clone for Id<T>

fn clone(&self) -> Id<T>

1.0.0fn clone_from(&mut self, source: &Self)

impl<T: Debug> Debug for Id<T>

fn fmt(&self, __arg_0: &mut Formatter) -> Result