Trait SerializableSocket

Source
pub trait SerializableSocket<T> {
    // Required methods
    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§

Source

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.

Source

fn get_id(&self) -> Option<T>

Returns id field.

Source

fn key(&self) -> &'static str

Field name of Json.

Source

fn addr(&self) -> &SocketAddr

Returns SocketAddr of the socket.

Source

fn ip(&self) -> IpAddr

Returns IpAddr of the socket.

Source

fn port(&self) -> u16

Returns port number of the socket.

Implementors§