pub struct WorkerAddress(/* private fields */);Expand description
Opaque worker address for discovery.
This is a transport-agnostic representation of a peer’s network address. The bytes are opaque to discovery and are interpreted by the active message runtime.
§Checksum
WorkerAddress implements a checksum via xxh3_64 for quick comparison during re-registration validation.
Implementations§
Source§impl WorkerAddress
impl WorkerAddress
Sourcepub fn from_encoded(bytes: impl Into<Bytes>) -> Self
pub fn from_encoded(bytes: impl Into<Bytes>) -> Self
Create a WorkerAddress from pre-encoded bytes.
This is used by transport implementations to construct addresses from MessagePack-encoded map data. The bytes are assumed to be valid MessagePack.
Sourcepub fn checksum(&self) -> u64
pub fn checksum(&self) -> u64
Compute a checksum of this address for validation.
This is used to quickly check if an address has changed during re-registration.
Sourcepub fn available_transports(
&self,
) -> Result<Vec<TransportKey>, WorkerAddressError>
pub fn available_transports( &self, ) -> Result<Vec<TransportKey>, WorkerAddressError>
Get the list of available transport keys in this address.
Returns the keys from the internal map as TransportKey for type-safe efficient
storage and sharing. This allows callers to see what transport types or endpoints
are available without exposing the full map.
§Errors
Returns an error if the internal bytes cannot be decoded as a valid MessagePack map.
§Example
let transports = address.available_transports().unwrap();
if transports.contains(&TransportKey::from("tcp")) {
// TCP transport is available
}Sourcepub fn get_entry(
&self,
key: impl AsRef<str>,
) -> Result<Option<Bytes>, WorkerAddressError>
pub fn get_entry( &self, key: impl AsRef<str>, ) -> Result<Option<Bytes>, WorkerAddressError>
Get a single entry from the internal map.
This decodes the address and extracts the entry for the given key.
Accepts any type that can be converted to a string reference, including
&str, String, &String, and TransportKey.
§Errors
Returns an error if the internal bytes cannot be decoded as a valid MessagePack map.
Trait Implementations§
Source§impl Clone for WorkerAddress
impl Clone for WorkerAddress
Source§fn clone(&self) -> WorkerAddress
fn clone(&self) -> WorkerAddress
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WorkerAddress
impl Debug for WorkerAddress
Source§impl<'de> Deserialize<'de> for WorkerAddress
impl<'de> Deserialize<'de> for WorkerAddress
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>,
Source§impl Display for WorkerAddress
impl Display for WorkerAddress
impl Eq for WorkerAddress
Source§impl Hash for WorkerAddress
impl Hash for WorkerAddress
Source§impl PartialEq for WorkerAddress
impl PartialEq for WorkerAddress
Source§fn eq(&self, other: &WorkerAddress) -> bool
fn eq(&self, other: &WorkerAddress) -> bool
self and other values to be equal, and is used by ==.