pub struct NetworkState {
pub version: u32,
pub networks: Vec<ManagedNetwork>,
}Expand description
The full marker file: every host-level network this node manages.
Fields§
§version: u32On-disk schema version.
networks: Vec<ManagedNetwork>Managed networks, keyed in practice by ManagedNetwork::owner.
Implementations§
Source§impl NetworkState
impl NetworkState
Sourcepub fn load(path: &Path) -> Self
pub fn load(path: &Path) -> Self
Load the marker file. A missing or unparseable file yields an empty state rather than an error — the marker is a best-effort cache that the live-host enumeration paths can always rebuild.
Sourcepub fn save(&self, path: &Path) -> Result<()>
pub fn save(&self, path: &Path) -> Result<()>
Persist the marker file, creating the parent directory if needed. Writes to a sibling temp file and renames so a crash mid-write can’t leave a truncated marker.
§Errors
Returns any I/O error from creating the directory, writing, or renaming.
Sourcepub fn get(&self, owner: &str) -> Option<&ManagedNetwork>
pub fn get(&self, owner: &str) -> Option<&ManagedNetwork>
Look up a managed network by owner.
Sourcepub fn upsert(&mut self, net: ManagedNetwork)
pub fn upsert(&mut self, net: ManagedNetwork)
Insert or replace the entry for net.owner.
Sourcepub fn remove(&mut self, owner: &str) -> Option<ManagedNetwork>
pub fn remove(&mut self, owner: &str) -> Option<ManagedNetwork>
Remove and return the entry for owner, if present.
Trait Implementations§
Source§impl Clone for NetworkState
impl Clone for NetworkState
Source§fn clone(&self) -> NetworkState
fn clone(&self) -> NetworkState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 NetworkState
impl Debug for NetworkState
Source§impl Default for NetworkState
impl Default for NetworkState
Source§impl<'de> Deserialize<'de> for NetworkState
impl<'de> Deserialize<'de> for NetworkState
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 NetworkState
impl RefUnwindSafe for NetworkState
impl Send for NetworkState
impl Sync for NetworkState
impl Unpin for NetworkState
impl UnsafeUnpin for NetworkState
impl UnwindSafe for NetworkState
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> FromBase64 for Twhere
T: for<'de> Deserialize<'de>,
impl<T> FromBase64 for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more