pub struct NodeState {
pub position: Option<Position>,
pub fuel_minutes: u32,
pub health: i32,
pub phase: i32,
pub cell_id: Option<String>,
pub zone_id: Option<String>,
pub timestamp: Option<Timestamp>,
}Expand description
Node dynamic state (mutable, LWW-Register)
Fields§
§position: Option<Position>Current position
fuel_minutes: u32Fuel remaining in minutes (PN-Counter)
health: i32Health status (LWW-Register)
phase: i32Current phase (LWW-Register)
cell_id: Option<String>Assigned cell ID (LWW-Register)
zone_id: Option<String>Assigned zone ID for hierarchical routing (LWW-Register)
timestamp: Option<Timestamp>Last update timestamp (for LWW conflict resolution)
Implementations§
Source§impl NodeState
impl NodeState
Sourcepub fn health(&self) -> HealthStatus
pub fn health(&self) -> HealthStatus
Returns the enum value of health, or the default if the field is set to an invalid enum value.
Sourcepub fn set_health(&mut self, value: HealthStatus)
pub fn set_health(&mut self, value: HealthStatus)
Sets health to the provided enum value.
Sourcepub fn phase(&self) -> Phase
pub fn phase(&self) -> Phase
Returns the enum value of phase, or the default if the field is set to an invalid enum value.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for NodeState
impl<'de> Deserialize<'de> for NodeState
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<NodeState, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<NodeState, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Message for NodeState
impl Message for NodeState
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Returns the encoded length of the message without a length delimiter.
Source§fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
Encodes the message to a buffer. Read more
Source§fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Encodes the message to a newly allocated buffer.
Source§fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
Encodes the message with a length-delimiter to a buffer. Read more
Source§fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Encodes the message with a length-delimiter to a newly allocated buffer.
Source§fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Decodes an instance of the message from a buffer. Read more
Source§fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Decodes a length-delimited instance of the message from the buffer.
Source§fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
Decodes an instance of the message from a buffer, and merges it into
self. Read moreSource§fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
Decodes a length-delimited instance of the message from buffer, and
merges it into
self.Source§impl NodeStateExt for NodeState
impl NodeStateExt for NodeState
Source§fn update_timestamp(&mut self)
fn update_timestamp(&mut self)
Update the timestamp to current time
Source§fn update_position(&mut self, position: (f64, f64, f64))
fn update_position(&mut self, position: (f64, f64, f64))
Update position (LWW-Register operation)
Source§fn get_health(&self) -> HealthStatus
fn get_health(&self) -> HealthStatus
Get health status
Source§fn update_health(&mut self, health: HealthStatus)
fn update_health(&mut self, health: HealthStatus)
Update health status (LWW-Register operation)
Source§fn update_phase(&mut self, phase: Phase)
fn update_phase(&mut self, phase: Phase)
Update phase (LWW-Register operation)
Source§fn assign_cell(&mut self, cell_id: String)
fn assign_cell(&mut self, cell_id: String)
Assign to a cell (LWW-Register operation)
Source§fn leave_cell(&mut self)
fn leave_cell(&mut self)
Remove from cell (LWW-Register operation)
Source§fn assign_zone(&mut self, zone_id: String)
fn assign_zone(&mut self, zone_id: String)
Assign to a zone (LWW-Register operation)
Source§fn leave_zone(&mut self)
fn leave_zone(&mut self)
Remove from zone (LWW-Register operation)
Source§fn consume_fuel(&mut self, minutes: u32)
fn consume_fuel(&mut self, minutes: u32)
Consume fuel (PN-Counter decrement operation)
Source§fn replenish_fuel(&mut self, minutes: u32)
fn replenish_fuel(&mut self, minutes: u32)
Replenish fuel (PN-Counter increment operation)
Source§fn is_operational(&self) -> bool
fn is_operational(&self) -> bool
Check if platform is operational
Source§fn needs_refuel(&self) -> bool
fn needs_refuel(&self) -> bool
Check if platform needs refueling (below 25% capacity)
Source§impl Serialize for NodeState
impl Serialize for NodeState
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for NodeState
Auto Trait Implementations§
impl Freeze for NodeState
impl RefUnwindSafe for NodeState
impl Send for NodeState
impl Sync for NodeState
impl Unpin for NodeState
impl UnsafeUnpin for NodeState
impl UnwindSafe for NodeState
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,
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