pub struct LocalState {
pub last_sync: Option<DateTime<Utc>>,
pub resources: HashMap<String, ResourceState>,
}Expand description
Local state tracking (.hoist/state.json)
Fields§
§last_sync: Option<DateTime<Utc>>Last sync timestamp
resources: HashMap<String, ResourceState>Resources by kind and name
Implementations§
Source§impl LocalState
impl LocalState
Sourcepub const STATE_FILE: &'static str = "state.json"
pub const STATE_FILE: &'static str = "state.json"
State file name
Sourcepub const CHECKSUMS_FILE: &'static str = "checksums.json"
pub const CHECKSUMS_FILE: &'static str = "checksums.json"
Checksums file name
Sourcepub fn state_file(project_root: &Path) -> PathBuf
pub fn state_file(project_root: &Path) -> PathBuf
Get the state file path
Sourcepub fn checksums_file(project_root: &Path) -> PathBuf
pub fn checksums_file(project_root: &Path) -> PathBuf
Get the checksums file path
Sourcepub fn load(project_root: &Path) -> Result<Self, StateError>
pub fn load(project_root: &Path) -> Result<Self, StateError>
Load state from disk
Sourcepub fn resource_key(kind: ResourceKind, name: &str) -> String
pub fn resource_key(kind: ResourceKind, name: &str) -> String
Get resource key
Sourcepub fn resource_key_managed(
kind: ResourceKind,
name: &str,
map: &ManagedMap,
) -> String
pub fn resource_key_managed( kind: ResourceKind, name: &str, map: &ManagedMap, ) -> String
Get resource key with managed map awareness.
Managed resources use their KS directory path as the key prefix, knowledge sources use their own directory, and standalone resources use the default directory.
Sourcepub fn get(&self, kind: ResourceKind, name: &str) -> Option<&ResourceState>
pub fn get(&self, kind: ResourceKind, name: &str) -> Option<&ResourceState>
Get resource state
Sourcepub fn set(&mut self, kind: ResourceKind, name: &str, state: ResourceState)
pub fn set(&mut self, kind: ResourceKind, name: &str, state: ResourceState)
Set resource state
Sourcepub fn remove(&mut self, kind: ResourceKind, name: &str)
pub fn remove(&mut self, kind: ResourceKind, name: &str)
Remove resource state
Sourcepub fn get_managed(
&self,
kind: ResourceKind,
name: &str,
map: &ManagedMap,
) -> Option<&ResourceState>
pub fn get_managed( &self, kind: ResourceKind, name: &str, map: &ManagedMap, ) -> Option<&ResourceState>
Get resource state using managed-aware key
Sourcepub fn set_managed(
&mut self,
kind: ResourceKind,
name: &str,
state: ResourceState,
map: &ManagedMap,
)
pub fn set_managed( &mut self, kind: ResourceKind, name: &str, state: ResourceState, map: &ManagedMap, )
Set resource state using managed-aware key
Sourcepub fn remove_managed(
&mut self,
kind: ResourceKind,
name: &str,
map: &ManagedMap,
)
pub fn remove_managed( &mut self, kind: ResourceKind, name: &str, map: &ManagedMap, )
Remove resource state using managed-aware key
Trait Implementations§
Source§impl Clone for LocalState
impl Clone for LocalState
Source§fn clone(&self) -> LocalState
fn clone(&self) -> LocalState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LocalState
impl Debug for LocalState
Source§impl Default for LocalState
impl Default for LocalState
Source§fn default() -> LocalState
fn default() -> LocalState
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for LocalState
impl<'de> Deserialize<'de> for LocalState
Source§fn 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
Auto Trait Implementations§
impl Freeze for LocalState
impl RefUnwindSafe for LocalState
impl Send for LocalState
impl Sync for LocalState
impl Unpin for LocalState
impl UnwindSafe for LocalState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more