Struct optee_utee::net::Socket

source ·
pub struct Socket<T: SocketAdapter> { /* private fields */ }
Expand description

A struct used for socket operations.

Implementations§

source§

impl<T: SocketAdapter> Socket<T>

source

pub fn open(setup: T::Setup) -> Result<Self, SocketError>

create a new connection, and then sending and receiving data over it.

source

pub fn set_recv_timeout_in_milli(&mut self, milliseconds: u32)

set timeout of recv operation.

source

pub fn set_send_timeout_in_milli(&mut self, milliseconds: u32)

set timeout of send operation.

source

pub fn set_recv_timeout(&mut self, dur: Option<Duration>) -> Result<()>

a wrapper of set_recv_timeout_in_milli, similar to set_read_timeout in std::net::TcpStream, it will set timeout to TEE_TIMEOUT_INFINITE if Option::None is provided.

source

pub fn set_send_timeout(&mut self, dur: Option<Duration>) -> Result<()>

a wrapper of set_send_timeout_in_milli, similar to set_write_timeout in std::net::TcpStream, it will set timeout to TEE_TIMEOUT_INFINITE if Option::None is provided.

source

pub fn send(&mut self, buf: &[u8]) -> Result<usize, SocketError>

send data, similar to write in io::Write

source

pub fn recv(&mut self, buf: &mut [u8]) -> Result<usize, SocketError>

recv data, similar to read in io::Read

Trait Implementations§

source§

impl<T: SocketAdapter<Setup = Setup>> StdCompatConnect for Socket<T>

source§

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

source§

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

source§

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

source§

impl<T: SocketAdapter<Setup = Setup>> StdCompatRead for Socket<T>

source§

fn read(&mut self, buf: &mut [u8]) -> Result<usize, SocketError>

source§

fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), SocketError>

source§

impl<T: SocketAdapter<Setup = Setup>> StdCompatWrite for Socket<T>

source§

fn write(&mut self, buf: &[u8]) -> Result<usize, SocketError>

source§

fn write_all(&mut self, buf: &[u8]) -> Result<(), SocketError>

Auto Trait Implementations§

§

impl<T> Freeze for Socket<T>
where <T as SocketAdapter>::Handle: Freeze,

§

impl<T> RefUnwindSafe for Socket<T>

§

impl<T> Send for Socket<T>
where <T as SocketAdapter>::Handle: Send,

§

impl<T> Sync for Socket<T>
where <T as SocketAdapter>::Handle: Sync,

§

impl<T> Unpin for Socket<T>
where <T as SocketAdapter>::Handle: Unpin,

§

impl<T> UnwindSafe for Socket<T>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.