pub(in crate::io::socket) mod inet;
pub(in crate::io::socket) mod prepared;
pub(in crate::io::socket) mod unix;
use std::net;
use dope_sys::io::socket::addr;
use crate::Backend;
#[derive(Clone, Copy)]
#[repr(transparent)]
pub struct Addr(addr::Storage<addr::Socklen>);
impl Addr {
pub fn from_std(address: net::SocketAddr) -> Self {
let native = addr::Internet::from_std::<Backend>(&address);
Self(addr::Storage::from_addr(native.as_addr()))
}
pub fn into_std(self) -> Result<net::SocketAddr, addr::Error> {
self.0.to_std()
}
}
impl From<prepared::View<'_>> for Addr {
fn from(view: prepared::View<'_>) -> Self {
Self(addr::Storage::from_addr(view.native()))
}
}