[−][src]Struct ipjdb::Collection
Group of items in the database
Implementations
impl Collection
[src]
pub fn get_all<T>(&self) -> Result<Vec<Item<T>>, Error> where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
Get all the items in the collection
pub fn find_many<T, F>(&self, f: F) -> Result<Vec<Item<T>>, Error> where
T: Deserialize<'de>,
F: Fn(&Item<T>) -> bool,
[src]
T: Deserialize<'de>,
F: Fn(&Item<T>) -> bool,
Get a subset of the items in the collection
Items are filtered by the function f
, which is passed an
Item
and should return true
to include that Item
in the
results, or false
to exclude it from the results.
pub fn get_one<T>(&self, id: &Id) -> Result<Item<T>, Error> where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
Get one item by its ID
pub fn insert_one<T>(&self, data: &T) -> Result<Id, Error> where
T: Serialize,
[src]
T: Serialize,
Insert one item into the collection
A unique ID will be generated for the item and returned.
pub fn delete_one(&self, id: &Id) -> Result<(), Error>
[src]
Delete one item from the collection
pub fn replace_one<T>(&self, item: &Item<T>) -> Result<(), Error> where
T: Serialize,
[src]
T: Serialize,
Overwrite one item in the collection
pub fn update_by_id<T, U>(&self, id: &Id, u: U) -> Result<(), Error> where
T: Deserialize<'de> + Serialize,
U: Fn(&mut Item<T>),
[src]
T: Deserialize<'de> + Serialize,
U: Fn(&mut Item<T>),
Find an item by its ID and update it
If the item is found, the function u
will be called with
that item. The function can modify the data as needed, and the
new item will be written to the collection. Note that the ID
cannot be modified.
pub fn update_many<T, F, U>(&self, f: F, u: U) -> Result<(), Error> where
T: Deserialize<'de> + Serialize,
F: Fn(&Item<T>) -> bool,
U: Fn(&mut Item<T>),
[src]
T: Deserialize<'de> + Serialize,
F: Fn(&Item<T>) -> bool,
U: Fn(&mut Item<T>),
Update a subset of the items in the collection
For each item in the collection the function f
is called
with that item. The function should return true
to update
the item or false
to leave it unmodified. For each item
where f
returned true
, the function u
is called to
update the item. The function can modify the data as needed,
and the new item will be written to the collection. Note that
the ID cannot be modified.
Trait Implementations
impl Clone for Collection
[src]
fn clone(&self) -> Collection
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for Collection
[src]
Auto Trait Implementations
impl RefUnwindSafe for Collection
impl Send for Collection
impl Sync for Collection
impl Unpin for Collection
impl UnwindSafe for Collection
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,