pub struct NodeApi { /* private fields */ }
Implementations§
Source§impl NodeApi
impl NodeApi
Sourcepub fn new(node_name: &str, node_version: &str) -> Self
pub fn new(node_name: &str, node_version: &str) -> Self
Creates a new instance of NodeApi
.
§Arguments
node_name
- A string slice that holds the name of the node.node_version
- A string slice that holds the version of the node.
§Returns
A new instance of NodeApi
with the specified node name and version,
and default health status set to Healthy
and an empty list of services.
Sourcepub fn update_health(&mut self, new_health: NodeHealth)
pub fn update_health(&mut self, new_health: NodeHealth)
Updates the health status of the node.
§Arguments
new_health
- The new health status to be set for the node.
Sourcepub fn register_service(
&mut self,
id: &str,
name: &str,
description: &str,
status: ServiceStatus,
)
pub fn register_service( &mut self, id: &str, name: &str, description: &str, status: ServiceStatus, )
Registers a new service with the node.
§Arguments
id
- A string slice that holds the unique identifier of the service.name
- A string slice that holds the name of the service.description
- A string slice that holds the description of the service.status
- The status of the service, represented by theServiceStatus
enum.
Sourcepub fn update_service_status(
&mut self,
service_id: &str,
status: ServiceStatus,
) -> Result<(), NodeApiError>
pub fn update_service_status( &mut self, service_id: &str, status: ServiceStatus, ) -> Result<(), NodeApiError>
Updates the status of a registered service.
§Arguments
service_id
- A string slice that holds the unique identifier of the service.status
- The new status to be set for the service, represented by theServiceStatus
enum.
§Returns
A Result
which is Ok(())
if the service status was updated successfully,
or an Err
with a message if the service with the specified id was not found.
Sourcepub fn deregister_service(
&mut self,
service_id: &str,
) -> Result<(), NodeApiError>
pub fn deregister_service( &mut self, service_id: &str, ) -> Result<(), NodeApiError>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for NodeApi
impl<'de> Deserialize<'de> for NodeApi
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 NodeApi
impl RefUnwindSafe for NodeApi
impl Send for NodeApi
impl Sync for NodeApi
impl Unpin for NodeApi
impl UnwindSafe for NodeApi
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