chore: run cargo format and delete empty lines in catalog.rs
This commit is contained in:
@@ -26,14 +26,12 @@ impl Catalog {
|
|||||||
..O::default()
|
..O::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initializes the database.
|
/// Initializes the database.
|
||||||
pub fn init(&self) -> result::Result<(), FailedTo> {
|
pub fn init(&self) -> result::Result<(), FailedTo> {
|
||||||
let path = path::Path::new(&self.path);
|
let path = path::Path::new(&self.path);
|
||||||
sqlite::init::db(path).map_err(|_| FailedTo::InitDatabase)?;
|
sqlite::init::db(path).map_err(|_| FailedTo::InitDatabase)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Inserts or updates a single object that implements the `EAV` trait into the catalog.
|
/// Inserts or updates a single object that implements the `EAV` trait into the catalog.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
@@ -49,7 +47,6 @@ impl Catalog {
|
|||||||
self.items.insert(entity.id.clone(), entity);
|
self.items.insert(entity.id.clone(), entity);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Inserts multiple objects that implement the `EAV` trait into the catalog.
|
/// Inserts multiple objects that implement the `EAV` trait into the catalog.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
@@ -61,7 +58,6 @@ impl Catalog {
|
|||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves an entity by its ID and converts it into a specified type `T`.
|
/// Retrieves an entity by its ID and converts it into a specified type `T`.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
@@ -80,7 +76,6 @@ impl Catalog {
|
|||||||
.map(|e| T::try_from(e.clone()).map_err(|_| FailedTo::ConvertEntity))
|
.map(|e| T::try_from(e.clone()).map_err(|_| FailedTo::ConvertEntity))
|
||||||
.transpose()
|
.transpose()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves the first entity that matches a given attribute and value.
|
/// Retrieves the first entity that matches a given attribute and value.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
@@ -108,7 +103,6 @@ impl Catalog {
|
|||||||
.map(|item| T::try_from(item.clone()).map_err(|_| FailedTo::ConvertEntity));
|
.map(|item| T::try_from(item.clone()).map_err(|_| FailedTo::ConvertEntity));
|
||||||
items.next().transpose()
|
items.next().transpose()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an iterator over entities of a specific class.
|
/// Returns an iterator over entities of a specific class.
|
||||||
///
|
///
|
||||||
/// # Returns
|
/// # Returns
|
||||||
@@ -123,7 +117,6 @@ impl Catalog {
|
|||||||
.filter(move |item| item.class == T::class())
|
.filter(move |item| item.class == T::class())
|
||||||
.map(|item| T::try_from(item.clone()).map_err(|_| FailedTo::ConvertEntity))
|
.map(|item| T::try_from(item.clone()).map_err(|_| FailedTo::ConvertEntity))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an iterator over entities that match a given attribute and value.
|
/// Returns an iterator over entities that match a given attribute and value.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
@@ -149,7 +142,6 @@ impl Catalog {
|
|||||||
.filter(move |item| item.value_of(attribute) == Some(&value))
|
.filter(move |item| item.value_of(attribute) == Some(&value))
|
||||||
.map(|item| T::try_from(item.clone()).map_err(|_| FailedTo::ConvertEntity))
|
.map(|item| T::try_from(item.clone()).map_err(|_| FailedTo::ConvertEntity))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Schedules an entity for deletion. Actual delition will take place when 'persist' is called.
|
/// Schedules an entity for deletion. Actual delition will take place when 'persist' is called.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
@@ -161,7 +153,6 @@ impl Catalog {
|
|||||||
entity.state = EntityState::ToDelete;
|
entity.state = EntityState::ToDelete;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Persists the current state of the catalog to the database.
|
/// Persists the current state of the catalog to the database.
|
||||||
///
|
///
|
||||||
/// - new entities will be written onto DB
|
/// - new entities will be written onto DB
|
||||||
@@ -185,7 +176,6 @@ impl Catalog {
|
|||||||
.collect();
|
.collect();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Loads an entity by its ID from the database into the catalog.
|
/// Loads an entity by its ID from the database into the catalog.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
@@ -199,7 +189,6 @@ impl Catalog {
|
|||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Loads all entities of a specific class from the database into the catalog.
|
/// Loads all entities of a specific class from the database into the catalog.
|
||||||
pub fn load_by_class<T>(&mut self) -> Result<(), FailedTo>
|
pub fn load_by_class<T>(&mut self) -> Result<(), FailedTo>
|
||||||
where
|
where
|
||||||
@@ -213,7 +202,6 @@ impl Catalog {
|
|||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Loads all entities matching the filter values
|
/// Loads all entities matching the filter values
|
||||||
/// Different entity class with clashing attribute names might be loaded
|
/// Different entity class with clashing attribute names might be loaded
|
||||||
pub fn load_by_filter(&mut self, filter: &Filter) -> Result<(), FailedTo> {
|
pub fn load_by_filter(&mut self, filter: &Filter) -> Result<(), FailedTo> {
|
||||||
|
|||||||
Reference in New Issue
Block a user