Skip to main content

base_scheduler/
address_info.rs

1// Released under the MIT License.
2// Copyright, 2026, by Samuel Williams.
3
4use crate::{AddressInfoView, SocketAddress, SocketProtocol, SocketType};
5
6/// An owned IP endpoint and its socket creation parameters. Obtain its domain with `SocketDomain::from(info.address)`; pass its type and protocol directly to `socket_open`.
7#[derive(Clone, Copy, Debug, Eq, PartialEq)]
8pub struct AddressInfo {
9    pub address: SocketAddress,
10    pub socket_type: SocketType,
11    /// `None` represents the resolver's zero/default protocol.
12    pub protocol: Option<SocketProtocol>,
13}
14
15impl AddressInfoView for AddressInfo {
16    fn address(&self) -> SocketAddress {
17        self.address
18    }
19
20    fn socket_type(&self) -> SocketType {
21        self.socket_type
22    }
23
24    fn protocol(&self) -> Option<SocketProtocol> {
25        self.protocol
26    }
27}