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 /// The resolved IP endpoint, including any IPv6 flow information and scope identifier.
10 pub address: SocketAddress,
11 /// The socket type to pass to `socket_open`.
12 pub socket_type: SocketType,
13 /// `None` represents the resolver's zero/default protocol.
14 pub protocol: Option<SocketProtocol>,
15}
16
17impl AddressInfoView for AddressInfo {
18 fn address(&self) -> SocketAddress {
19 self.address
20 }
21
22 fn socket_type(&self) -> SocketType {
23 self.socket_type
24 }
25
26 fn protocol(&self) -> Option<SocketProtocol> {
27 self.protocol
28 }
29}