pub trait SerializableSocket<T> {
fn try_create(id: Option<String>, ip: &str, port: u16) -> Result<Self, Error>
where
Self: Sized;
fn get_id(&self) -> Option<T>;
fn key(&self) -> &'static str;
fn addr(&self) -> &SocketAddr;
fn ip(&self) -> IpAddr;
fn port(&self) -> u16;
}
Expand description
This trait is for serializing SocketInfo to JSON.
It also has some getter functions.
Required Methods
sourcefn try_create(id: Option<String>, ip: &str, port: u16) -> Result<Self, Error>where
Self: Sized,
fn try_create(id: Option<String>, ip: &str, port: u16) -> Result<Self, Error>where
Self: Sized,
Create an instance of SerializableSocket.
Failures
It returns error, if the ip and port is not valid for SocketAddr.
sourcefn addr(&self) -> &SocketAddr
fn addr(&self) -> &SocketAddr
Returns SocketAddr of the socket.