Trait optee_utee::net::StdCompatConnect

source ·
pub trait StdCompatConnect: Sized {
    // Required methods
    fn connect_v4(address: &str, port: u16) -> Result<Self, SocketError>;
    fn connect_v6(address: &str, port: u16) -> Result<Self, SocketError>;

    // Provided method
    fn connect(address: &str, port: u16) -> Result<Self, SocketError> { ... }
}
Expand description

A trait used for convenience; import it so that the code remains consistent with the std version (with the only difference being the return error type).

Take TcpStream as example:

use optee_utee::net::{Setup, TcpStream, SocketError};

fn connect_without_compact_trait(host: &str, port: u16) -> Result<TcpStream, SocketError> {
    let setup = Setup::new_v4(host, port)?;
    TcpStream::open(setup)
}

fn connect_with_compact_trait(host: &str, port: u16) -> Result<TcpStream, SocketError> {
    use optee_utee::net::StdCompatConnect;

    TcpStream::connect_v4(host, port)
}

Required Methods§

source

fn connect_v4(address: &str, port: u16) -> Result<Self, SocketError>

source

fn connect_v6(address: &str, port: u16) -> Result<Self, SocketError>

Provided Methods§

source

fn connect(address: &str, port: u16) -> Result<Self, SocketError>

Object Safety§

This trait is not object safe.

Implementors§