Struct thermite::model::LocalIndex
source · pub struct LocalIndex {
pub mods: BTreeMap<String, LocalMod>,
pub linked: BTreeMap<String, LocalMod>,
/* private fields */
}Expand description
Index of mods installed locally
Will save itself when it goes out of scope
Fields
mods: BTreeMap<String, LocalMod>linked: BTreeMap<String, LocalMod>Implementations
sourceimpl LocalIndex
impl LocalIndex
sourcepub fn load_or_create(path: impl AsRef<Path>) -> Self
pub fn load_or_create(path: impl AsRef<Path>) -> Self
Tries to load an existing RON-format index file, or creates one if it doesn’t exist
Params
- path - Path to file to try to load
sourcepub fn save(&self) -> Result<(), ThermiteError>
pub fn save(&self) -> Result<(), ThermiteError>
Save the index file
This function will be called when the LocalIndex is dropped. It shouldn’t need to be called manually.
sourcepub fn parent_dir(&self) -> PathBuf
pub fn parent_dir(&self) -> PathBuf
Returns the parent directory of the index file if available,
or a default PathBuf otherwise
sourcepub fn save_if_changed(&self) -> bool
pub fn save_if_changed(&self) -> bool
Calls LocalIndex::save only if the index was modified
Returns whether or not the index was written to disk
pub fn path(&self) -> &PathBuf
pub fn path_mut(&mut self) -> &mut PathBuf
pub fn get_mod(&self, name: &str) -> Option<&LocalMod>
pub fn get_sub_mod(&self, name: &str) -> Option<&SubMod>
Trait Implementations
sourceimpl Clone for LocalIndex
impl Clone for LocalIndex
sourcefn clone(&self) -> LocalIndex
fn clone(&self) -> LocalIndex
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresourceimpl Debug for LocalIndex
impl Debug for LocalIndex
sourceimpl Default for LocalIndex
impl Default for LocalIndex
sourcefn default() -> LocalIndex
fn default() -> LocalIndex
Returns the “default value” for a type. Read more
sourceimpl<'de> Deserialize<'de> for LocalIndex
impl<'de> Deserialize<'de> for LocalIndex
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
sourceimpl Drop for LocalIndex
impl Drop for LocalIndex
sourceimpl Hash for LocalIndex
impl Hash for LocalIndex
sourceimpl Serialize for LocalIndex
impl Serialize for LocalIndex
Auto Trait Implementations
impl RefUnwindSafe for LocalIndex
impl Send for LocalIndex
impl Sync for LocalIndex
impl Unpin for LocalIndex
impl UnwindSafe for LocalIndex
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