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.