pub struct ServiceInfo {
pub id: Uuid,
pub name: String,
pub service_type: ServiceType,
pub address: IpAddr,
pub port: u16,
pub attributes: ServiceAttributes,
pub protocol_type: ProtocolType,
pub discovered_at: SystemTime,
pub ttl: Duration,
pub verified: bool,
pub interface: Option<String>,
}Expand description
ServiceInfo holds information about a discovered or registered service
Fields§
§id: UuidUnique identifier for this service instance
name: StringHuman-readable name of the service
service_type: ServiceTypeService type (e.g., “_http._tcp”)
address: IpAddrIP address of the service
port: u16Port number of the service
attributes: ServiceAttributesAdditional service attributes
protocol_type: ProtocolTypeProtocol used to discover this service
discovered_at: SystemTimeTime when the service was discovered
ttl: DurationTime-to-live for the service record
verified: boolWhether the service has been verified
interface: Option<String>Network interface name where the service was discovered
Implementations§
Source§impl ServiceInfo
impl ServiceInfo
Sourcepub fn new(
name: impl Into<String>,
service_type: impl Into<String>,
port: u16,
attributes: Option<Vec<(&str, &str)>>,
) -> Result<Self, DiscoveryError>
pub fn new( name: impl Into<String>, service_type: impl Into<String>, port: u16, attributes: Option<Vec<(&str, &str)>>, ) -> Result<Self, DiscoveryError>
Create a new service info
Sourcepub fn protocol_type(&self) -> ProtocolType
pub fn protocol_type(&self) -> ProtocolType
Get protocol type used for this service
Sourcepub fn with_protocol_type(self, protocol_type: ProtocolType) -> Self
pub fn with_protocol_type(self, protocol_type: ProtocolType) -> Self
Set protocol type
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if service has expired
Sourcepub fn with_attributes<K, V>(self, attrs: HashMap<K, V>) -> Self
pub fn with_attributes<K, V>(self, attrs: HashMap<K, V>) -> Self
Set service attributes
Sourcepub fn with_attribute<K: Into<String>, V: Into<String>>(
self,
key: K,
value: V,
) -> Self
pub fn with_attribute<K: Into<String>, V: Into<String>>( self, key: K, value: V, ) -> Self
Set a single attribute
Sourcepub fn insert_attribute<K: Into<String>, V: Into<String>>(
&mut self,
key: K,
value: V,
)
pub fn insert_attribute<K: Into<String>, V: Into<String>>( &mut self, key: K, value: V, )
Insert or update an attribute
Sourcepub fn get_attribute(&self, key: &str) -> Option<&String>
pub fn get_attribute(&self, key: &str) -> Option<&String>
Get an attribute value
Sourcepub fn with_address(self, address: IpAddr) -> Self
pub fn with_address(self, address: IpAddr) -> Self
Set service address
Sourcepub fn service_type(&self) -> &ServiceType
pub fn service_type(&self) -> &ServiceType
Get service type
Trait Implementations§
Source§impl Clone for ServiceInfo
impl Clone for ServiceInfo
Source§fn clone(&self) -> ServiceInfo
fn clone(&self) -> ServiceInfo
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ServiceInfo
impl Debug for ServiceInfo
Source§impl<'de> Deserialize<'de> for ServiceInfo
impl<'de> Deserialize<'de> for ServiceInfo
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
Source§impl Display for ServiceInfo
impl Display for ServiceInfo
Source§impl PartialEq for ServiceInfo
impl PartialEq for ServiceInfo
Source§impl Serialize for ServiceInfo
impl Serialize for ServiceInfo
impl Eq for ServiceInfo
impl StructuralPartialEq for ServiceInfo
Auto Trait Implementations§
impl Freeze for ServiceInfo
impl RefUnwindSafe for ServiceInfo
impl Send for ServiceInfo
impl Sync for ServiceInfo
impl Unpin for ServiceInfo
impl UnwindSafe for ServiceInfo
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