Skip to main content

IAsyncToken

Trait IAsyncToken 

Source
pub trait IAsyncToken {
    type Controller: IController;

    // Required methods
    fn get_session_id(&self) -> i64;
    fn new_serial(&self) -> i64;
    fn get_peer(&self) -> impl Future<Output = Option<Arc<NetPeer>>>;
    fn send(&self, buff: Vec<u8>) -> impl Future<Output = Result<()>>;
    fn get_token(
        &self,
        session_id: i64,
    ) -> impl Future<Output = Result<Option<NetxToken<Self::Controller>>>>;
    fn get_all_tokens(
        &self,
    ) -> impl Future<Output = Result<Vec<NetxToken<Self::Controller>>>>;
    fn call(
        &self,
        serial: i64,
        buff: Data,
    ) -> impl Future<Output = Result<RetResult>>;
    fn run(&self, buff: Data) -> impl Future<Output = Result<()>>;
    fn is_disconnect(&self) -> impl Future<Output = bool>;
}
Expand description

Trait defining the interface for an asynchronous token.

Required Associated Types§

Source

type Controller: IController

The type of the controller.

Required Methods§

Source

fn get_session_id(&self) -> i64

Gets the session ID associated with the token.

§Returns
  • i64 - The session ID.
Source

fn new_serial(&self) -> i64

Generates a new serial ID.

§Returns
  • i64 - The new serial ID.
Source

fn get_peer(&self) -> impl Future<Output = Option<Arc<NetPeer>>>

Gets the TCP socket peer.

§Returns
  • impl std::future::Future<Output = Option<Arc<NetPeer>>> - A future that resolves to an optional Arc reference to the network peer.
Source

fn send(&self, buff: Vec<u8>) -> impl Future<Output = Result<()>>

Sends a buffer.

§Arguments
  • buff - The buffer to send.
§Returns
  • impl std::future::Future<Output = Result<()>> - A future that resolves to a Result.
Source

fn get_token( &self, session_id: i64, ) -> impl Future<Output = Result<Option<NetxToken<Self::Controller>>>>

Gets the network token by session ID.

§Arguments
  • session_id - The session ID.
§Returns
  • impl std::future::Future<Output = Result<Option<NetxToken<Self::Controller>>>> - A future that resolves to an optional NetxToken.
Source

fn get_all_tokens( &self, ) -> impl Future<Output = Result<Vec<NetxToken<Self::Controller>>>>

Gets all network tokens.

§Returns
  • impl std::future::Future<Output = Result<Vec<NetxToken<Self::Controller>>>> - A future that resolves to a vector of NetxToken.
Source

fn call( &self, serial: i64, buff: Data, ) -> impl Future<Output = Result<RetResult>>

Calls a function with the given serial and buffer.

§Arguments
  • serial - The serial number.
  • buff - The buffer to send.
§Returns
  • impl std::future::Future<Output = Result<RetResult>> - A future that resolves to a RetResult.
Source

fn run(&self, buff: Data) -> impl Future<Output = Result<()>>

Runs a function with the given buffer.

§Arguments
  • buff - The buffer to send.
§Returns
  • impl std::future::Future<Output = Result<()>> - A future that resolves to a Result.
Source

fn is_disconnect(&self) -> impl Future<Output = bool>

Checks if the connection is disconnected.

§Returns
  • impl std::future::Future<Output = bool> - A future that resolves to a boolean indicating if the connection is disconnected.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§