pub struct NodeRegistry {
pub schema_version: u32,
pub next_id: u32,
pub path: PathBuf,
/* private fields */
}Expand description
Persisted node registry (JSON file on disk).
Fields§
§schema_version: u32§next_id: u32§path: PathBufPath where this registry is persisted. Not serialized.
Implementations§
Source§impl NodeRegistry
impl NodeRegistry
Sourcepub fn load(path: &Path) -> Result<Self>
pub fn load(path: &Path) -> Result<Self>
Load the registry from disk, or create an empty one if the file doesn’t exist.
Sourcepub fn load_locked(path: &Path) -> Result<(Self, File)>
pub fn load_locked(path: &Path) -> Result<(Self, File)>
Load the registry with an exclusive file lock.
Returns the registry and the lock file handle. The lock is held until the file handle is dropped, so callers should keep it alive for the duration of their read-modify-write cycle.
Sourcepub fn save(&self) -> Result<()>
pub fn save(&self) -> Result<()>
Save the registry to disk atomically.
Writes to a temporary file first, then renames to the target path. This prevents registry corruption if the process crashes mid-write.
Sourcepub fn get(&self, id: u32) -> Result<&NodeConfig>
pub fn get(&self, id: u32) -> Result<&NodeConfig>
Get a node by ID.
Sourcepub fn get_mut(&mut self, id: u32) -> Result<&mut NodeConfig>
pub fn get_mut(&mut self, id: u32) -> Result<&mut NodeConfig>
Get a mutable reference to a node by ID.
Sourcepub fn add(&mut self, config: NodeConfig) -> u32
pub fn add(&mut self, config: NodeConfig) -> u32
Add a node and return its assigned ID.
Sourcepub fn add_batch(&mut self, configs: Vec<NodeConfig>) -> Vec<u32>
pub fn add_batch(&mut self, configs: Vec<NodeConfig>) -> Vec<u32>
Add multiple nodes at once and return their assigned IDs.
Sourcepub fn remove(&mut self, id: u32) -> Result<NodeConfig>
pub fn remove(&mut self, id: u32) -> Result<NodeConfig>
Remove a node by ID.
Sourcepub fn list(&self) -> Vec<&NodeConfig>
pub fn list(&self) -> Vec<&NodeConfig>
List all nodes.
Sourcepub fn find_by_service_name(&self, name: &str) -> Option<&NodeConfig>
pub fn find_by_service_name(&self, name: &str) -> Option<&NodeConfig>
Find a node by its service name.
Trait Implementations§
Source§impl Clone for NodeRegistry
impl Clone for NodeRegistry
Source§fn clone(&self) -> NodeRegistry
fn clone(&self) -> NodeRegistry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NodeRegistry
impl Debug for NodeRegistry
Source§impl<'de> Deserialize<'de> for NodeRegistry
impl<'de> Deserialize<'de> for NodeRegistry
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>,
Auto Trait Implementations§
impl Freeze for NodeRegistry
impl RefUnwindSafe for NodeRegistry
impl Send for NodeRegistry
impl Sync for NodeRegistry
impl Unpin for NodeRegistry
impl UnsafeUnpin for NodeRegistry
impl UnwindSafe for NodeRegistry
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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