Struct libfortress::Directory
source · [−]Expand description
A directory is a list of references to Entries and Directories, much like a filesystem directory. History is always ordered (by timestamp) and consistent (no double adds or removes of non-existant IDs).
Fields
entries: HashSet<ID>
name: Option<String>
Implementations
sourceimpl Directory
impl Directory
pub fn new() -> Directory
pub fn new_root() -> Directory
pub fn get_id(&self) -> &ID
pub fn get_history(&self) -> &[DirectoryHistory]
pub fn get_name(&self) -> Option<&str>
pub fn add(&mut self, id: ID)
pub fn add_with_time(&mut self, id: ID, time: u64)
pub fn remove(&mut self, id: ID)
pub fn remove_with_time(&mut self, id: ID, time: u64)
pub fn rename<S: Into<String>>(&mut self, name: S)
pub fn rename_with_time<S: Into<String>>(&mut self, name: S, time: u64)
sourcepub fn list_entries<'a>(&'a self, database: &Database) -> Vec<&'a ID>
pub fn list_entries<'a>(&'a self, database: &Database) -> Vec<&'a ID>
List all Entry entries in this directory.
sourcepub fn list_directories<'a>(
&'a self,
database: &'a Database
) -> impl Iterator<Item = &'a ID> + '_
pub fn list_directories<'a>(
&'a self,
database: &'a Database
) -> impl Iterator<Item = &'a ID> + '_
List all Directory entries in this directory.
pub fn contains(&self, id: &ID) -> bool
sourcepub fn merge(&self, other: &Directory) -> Option<Directory>
pub fn merge(&self, other: &Directory) -> Option<Directory>
Merge self and other, returning a new Directory. Returns None if there is a conflict.
sourcepub fn safe_to_replace_with(&self, other: &Directory) -> bool
pub fn safe_to_replace_with(&self, other: &Directory) -> bool
Returns true only if it is safe to replace self with other in the Database. This is only true if doing so is a non-destructive operation (i.e. history is perserved).
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Directory
impl<'de> Deserialize<'de> for Directory
sourcefn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Directory
impl StructuralEq for Directory
impl StructuralPartialEq for Directory
Auto Trait Implementations
impl RefUnwindSafe for Directory
impl Send for Directory
impl Sync for Directory
impl Unpin for Directory
impl UnwindSafe for Directory
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.