Struct Connection

Source
pub struct Connection {
    pub reader: BufReader<NetStream>,
    pub writer: BufWriter<NetStream>,
    /* private fields */
}
Expand description

A Connection object. Make sure you syncronize if uses in multiple threads

Fields§

§reader: BufReader<NetStream>

BufReader for NetStream (TCP/SSL)

§writer: BufWriter<NetStream>

BufWriter for NetStream (TCP/SSL)

Implementations§

Source§

impl Connection

Implementation for Connectio

Source

pub fn get_peer_address(&self) -> &String

Source

pub fn get_local_address(&self) -> &String

Source

pub fn connect(config: &Config) -> Result<Connection>

connection unique id Creates a TCP connection to the specified server.

Source

pub fn reconnect(&mut self) -> Result<Connection>

Creates a TCP/SSL connection to the specified server. If already connected, it will drop and reconnect

Source

pub fn id(&self) -> &String

Get the connection id

Source

pub fn is_valid(&self) -> bool

Is Valid connection

Auto Trait Implementations§

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>,

Source§

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>,

Source§

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.