Collection

Struct Collection 

Source
pub struct Collection<T: StandardObject> { /* private fields */ }
Expand description

Collections.

Implementations§

Source§

impl<T: StandardObject> Collection<T>

Source

pub fn new() -> Self

Source

pub fn find(&self, search: &StdPropsFilter) -> HashSet<T>

Finds all objects with properties matching the search criteria.

Source

pub fn find_one(&self, search: &StdPropsFilter) -> Option<T>

Finds a single instance of an object with properties matching the search filter.

Source

pub fn insert_one(&mut self, obj: T) -> Result

Inserts a single object into the database.

§Errors
  • If an object with the same resource id already exists.
Source

pub fn update(&mut self, uid: Uuid, obj: T) -> Result<T>

Updates an object given its universal id. The object’s universal id is not altered from the object passed in for the update, however other aspects of the resource id may be.

§Returns

The old value.

§Errors
  • If an object with the given universal id is not found.
Source

pub fn update_one(&mut self, search: &RidFilter, obj: T) -> Result<T>

Updates the properties a single object.

§Returns

Returns the orginal value.

§Errors
  • If no objects match the search.
  • If more than one object matches the search.
Source

pub fn update_or_insert_one( &mut self, search: &RidFilter, obj: T, ) -> Result<Option<T>>

Updates an object if one is found, otherwise inserts it as new. If inserting a new object, the resource id is taken as is. If updating a previous object, the resource id aremains as the original’s.

§Returns

None if the object was newly inserted, or Some with the old value if it was updated.

§Errors
  • If more than one object matches the search.
Source

pub fn len(&self) -> usize

Returns the number of objects in the collection.

Trait Implementations§

Source§

impl<T: Debug + StandardObject> Debug for Collection<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Collection<T>

§

impl<T> RefUnwindSafe for Collection<T>
where T: RefUnwindSafe,

§

impl<T> Send for Collection<T>
where T: Send,

§

impl<T> Sync for Collection<T>
where T: Sync,

§

impl<T> Unpin for Collection<T>
where T: Unpin,

§

impl<T> UnwindSafe for Collection<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,