Struct GnsSocket

Source
pub struct GnsSocket<S> { /* private fields */ }
Expand description

GnsSocket is the most important structure of this library. This structure is used to create client (GnsSocket<IsClient>) and server (GnsSocket<IsServer>) sockets via the GnsSocket::connect and GnsSocket::listen functions. The drop implementation make sure that everything related to this structure is correctly freed, except the GnsGlobal instance and the user has a strong guarantee that all the available operations over the socket are safe.

Implementations§

Source§

impl<S> GnsSocket<S>
where S: IsReady,

Source

pub fn get_connection_real_time_status( &self, GnsConnection: GnsConnection, nb_of_lanes: u32, ) -> GnsResult<(GnsConnectionRealTimeStatus, Vec<GnsConnectionRealTimeLaneStatus>)>

Get a connection lane status. This call is possible only if lanes has been previously configured using configure_connection_lanes

Source

pub fn get_connection_info( &self, GnsConnection: GnsConnection, ) -> Option<GnsConnectionInfo>

Source

pub fn flush_messages_on_connection( &self, GnsConnection: GnsConnection, ) -> GnsResult<()>

Source

pub fn close_connection( &self, GnsConnection: GnsConnection, reason: u32, debug: &str, linger: bool, ) -> bool

Source

pub fn poll_messages<const K: usize>( &self, message_callback: impl FnMut(&GnsNetworkMessage<ToReceive>), ) -> Option<usize>

Source

pub fn poll_event<const K: usize>( &self, event_callback: impl FnMut(GnsConnectionEvent), ) -> usize

Source

pub fn configure_connection_lanes( &self, GnsConnection: GnsConnection, lanes: &[GnsLane], ) -> GnsResult<()>

Source

pub fn send_messages( &self, messages: Vec<GnsNetworkMessage<ToSend>>, ) -> Vec<Either<GnsMessageNumber, EResult>>

Source§

impl GnsSocket<IsCreated>

Source

pub fn new(global: Arc<GnsGlobal>) -> Self

Initialize a new socket in IsCreated state.

Source

pub fn listen( self, address: IpAddr, port: u16, ) -> Result<GnsSocket<IsServer>, ()>

Listen for incoming connections, the socket transition from IsCreated to IsServer, allowing a new set of server operations.

Source

pub fn connect( self, address: IpAddr, port: u16, ) -> Result<GnsSocket<IsClient>, ()>

Connect to a remote host, the socket transition from IsCreated to IsClient, allowing a new set of client operations.

Source§

impl GnsSocket<IsServer>

Source

pub fn accept(&self, connection: GnsConnection) -> GnsResult<()>

Accept an incoming connection. This operation is available only if the socket is in the IsServer state.

Source§

impl GnsSocket<IsClient>

Source

pub fn connection(&self) -> GnsConnection

Return the socket connection. This operation is available only if the socket is in the IsClient state.

Auto Trait Implementations§

§

impl<S> Freeze for GnsSocket<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for GnsSocket<S>
where S: RefUnwindSafe,

§

impl<S> Send for GnsSocket<S>
where S: Send,

§

impl<S> Sync for GnsSocket<S>
where S: Sync,

§

impl<S> Unpin for GnsSocket<S>
where S: Unpin,

§

impl<S> UnwindSafe for GnsSocket<S>
where S: UnwindSafe,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.