pub struct SquadState {
pub config: Option<CellConfig>,
pub leader_id: Option<String>,
pub members: Vec<String>,
pub capabilities: Vec<Capability>,
pub platoon_id: Option<String>,
pub timestamp: Option<Timestamp>,
}Expand description
Cell state (dynamic)
Fields§
§config: Option<CellConfig>Cell configuration
leader_id: Option<String>Current cell leader node ID (LWW-Register)
members: Vec<String>Set of member node IDs (OR-Set)
capabilities: Vec<Capability>Aggregated cell capabilities (G-Set: grow-only)
platoon_id: Option<String>Parent platoon/zone ID for hierarchy (LWW-Register)
timestamp: Option<Timestamp>Last update timestamp (for LWW conflict resolution)
Implementations§
Trait Implementations§
Source§impl CellStateExt for CellState
impl CellStateExt for CellState
Source§fn new(config: CellConfig) -> Self
fn new(config: CellConfig) -> Self
Create a new cell state
Source§fn update_timestamp(&mut self)
fn update_timestamp(&mut self)
Update the timestamp to current time
Source§fn add_member(&mut self, node_id: String) -> bool
fn add_member(&mut self, node_id: String) -> bool
Add a member to the cell (OR-Set add operation) Read more
Source§fn remove_member(&mut self, node_id: &str) -> bool
fn remove_member(&mut self, node_id: &str) -> bool
Remove a member from the cell (OR-Set remove operation)
Source§fn set_leader(&mut self, node_id: String) -> Result<(), &'static str>
fn set_leader(&mut self, node_id: String) -> Result<(), &'static str>
Set the cell leader (LWW-Register operation) Read more
Source§fn clear_leader(&mut self)
fn clear_leader(&mut self)
Clear the cell leader
Source§fn add_capability(&mut self, capability: Capability)
fn add_capability(&mut self, capability: Capability)
Add a capability to the cell (G-Set operation) Read more
Source§fn get_capabilities_by_type(
&self,
capability_type: CapabilityType,
) -> Vec<&Capability>
fn get_capabilities_by_type( &self, capability_type: CapabilityType, ) -> Vec<&Capability>
Get all capabilities of a specific type
Source§fn has_capability_type(&self, capability_type: CapabilityType) -> bool
fn has_capability_type(&self, capability_type: CapabilityType) -> bool
Check if cell has a specific capability type
Source§fn assign_platoon(&mut self, platoon_id: String)
fn assign_platoon(&mut self, platoon_id: String)
Assign cell to a platoon (LWW-Register operation)
Source§fn leave_platoon(&mut self)
fn leave_platoon(&mut self)
Remove cell from platoon
Source§fn member_count(&self) -> usize
fn member_count(&self) -> usize
Get the count of members
Source§impl<'de> Deserialize<'de> for CellState
impl<'de> Deserialize<'de> for CellState
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<CellState, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<CellState, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Message for CellState
impl Message for CellState
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 Serialize for CellState
impl Serialize for CellState
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 CellState
Auto Trait Implementations§
impl Freeze for CellState
impl RefUnwindSafe for CellState
impl Send for CellState
impl Sync for CellState
impl Unpin for CellState
impl UnsafeUnpin for CellState
impl UnwindSafe for CellState
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