Struct ohmers::Set [] [src]

pub struct Set<T: Ohmer> {
    // some fields omitted
}

An unordered collection of items.

Examples

model!(
    Task {
        body:String = "".to_string();
    });
model!(
    Queue {
        tasks: Set<Task> = Set::new();
    });
let queue = create!(Queue {}, &client).unwrap();
let t1 = create!(Task { body: "task1".to_string() }, &client).unwrap();
let t2 = create!(Task { body: "task2".to_string() }, &client).unwrap();
let t3 = create!(Task { body: "task3".to_string() }, &client).unwrap();
insert!(queue.tasks, t1, client).unwrap();
insert!(queue.tasks, t2, client).unwrap();
insert!(queue.tasks, t3, client).unwrap();
assert_eq!(len!(queue.tasks, client).unwrap(), 3);
assert!(remove!(queue.tasks, t1, client).unwrap());
assert_eq!(len!(queue.tasks, client).unwrap(), 2);

Methods

impl<T: Ohmer> Set<T>

fn new() -> Self

fn key<P: Ohmer>(&self, property: &str, parent: &P) -> Result<Set, OhmerError>

Gets a stal::Set pointing to the key containing the set.

fn query<'a, P: Ohmer>(&'a self, property: &str, parent: &P, r: &'a Client) -> Result<Query<T>, OhmerError>

Gets a Query object for all the elements in the set.

fn insert<P: Ohmer>(&self, property: &str, parent: &P, obj: &T, r: &Client) -> Result<bool, OhmerError>

Adds an element to the set. Returns true when the element was added, false if it was already present.

fn remove<P: Ohmer>(&self, property: &str, parent: &P, obj: &T, r: &Client) -> Result<bool, OhmerError>

Removes an element to the set. Returns true when the element was removed, false if it was already absent.

fn contains<P: Ohmer>(&self, property: &str, parent: &P, obj: &T, r: &Client) -> Result<bool, OhmerError>

Returns true if the element is in the set.

fn len<P: Ohmer>(&self, property: &str, parent: &P, r: &Client) -> Result<usize, OhmerError>

Counts the number of elements in the set.

Trait Implementations

Derived Implementations

impl<T: Clone + Ohmer> Clone for Set<T>

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

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

impl<T: Debug + Ohmer> Debug for Set<T>

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

impl<T: PartialEq + Ohmer> PartialEq for Set<T>

fn eq(&self, __arg_0: &Set<T>) -> bool

fn ne(&self, __arg_0: &Set<T>) -> bool

impl<T: Decodable + Ohmer> Decodable for Set<T>

fn decode<__D: Decoder>(__arg_0: &mut __D) -> Result<Set<T>, __D::Error>

impl<T: Encodable + Ohmer> Encodable for Set<T>

fn encode<__S: Encoder>(&self, __arg_0: &mut __S) -> Result<(), __S::Error>