Struct Actor

Source
pub struct Actor<I> { /* private fields */ }
Expand description

Actor Model Ensure Thread safety and high performance writing

Implementations§

Source§

impl<I> Actor<I>
where I: 'static,

Source

pub fn new(x: I) -> Actor<I>

Source

pub async fn inner_call<T, R>( &self, call: impl FnOnce(Arc<InnerStore<I>>) -> T, ) -> R
where T: Future<Output = R>,

Behavior through queues,thread safe call async fn

Source

pub unsafe fn deref_inner(&self) -> RefInner<'_, I>

§Safety

This is a thread unsafe way to get When using, please make sure there is no thread safety problem

Trait Implementations§

Source§

impl<I> Default for Actor<I>
where I: Default,

Source§

fn default() -> Actor<I>

Returns the “default value” for a type. Read more
Source§

impl<T: SessionSave + 'static> INetXClient for Actor<NetXClient<T>>

Implementation of the INetXClient trait for Actor<NetXClient<T>>.

This implementation provides the external operations for the NetXClient, including methods for initializing the controller, connecting to the network, getting configuration and session information, generating serial IDs, and checking connection status.

Source§

async fn init<C: IController + Sync + Send + 'static>(&self, controller: C)

Initializes the NetX client controller. Read more
Source§

async fn connect_network(self: &Arc<Self>) -> Result<()>

Connects to the network. Read more
Source§

fn get_tls_config(&self) -> TlsConfig

Gets the TLS configuration. Read more
Source§

fn get_address(&self) -> String

Gets the NetX server address. Read more
Source§

fn get_service_info(&self) -> ServerOption

Gets the NetX client service configuration. Read more
Source§

fn get_session_id(&self) -> i64

Gets the NetX session ID. Read more
Source§

fn get_mode(&self) -> u8

Gets the NetX mode. Read more
Source§

fn new_serial(&self) -> i64

Generates a new serial ID. Read more
Source§

fn is_connect(&self) -> bool

Checks if the client is connected to the server. Read more
Source§

async fn get_peer(&self) -> Option<Arc<NetPeer>>

Gets the TCP socket peer. Read more
Source§

async fn set_network_client(&self, client: Arc<NetPeer>)

Sets the TCP socket peer. Read more
Source§

async fn get_callback_len(&self) -> usize

Gets the length of the request wait callback. Read more
Source§

async fn close(&self) -> Result<()>

Closes the NetX client. Read more
Source§

async fn call(&self, serial: i64, buff: Data) -> Result<RetResult>

Calls a function with the given serial and buffer. Read more
Source§

async fn run(&self, buff: Data) -> Result<()>

Runs the client with the given buffer. Read more
Source§

impl<T> SocketClientTrait for Actor<TcpClient<T>>
where T: AsyncRead + AsyncWrite + Send + 'static,

Source§

async fn send<B>(&self, buff: B) -> Result<usize, Error>
where B: Deref<Target = [u8]> + Send + Sync + 'static,

Source§

async fn send_all<B>(&self, buff: B) -> Result<(), Error>
where B: Deref<Target = [u8]> + Send + Sync + 'static,

Source§

async fn send_ref(&self, buff: &[u8]) -> Result<usize, Error>

Source§

async fn send_all_ref(&self, buff: &[u8]) -> Result<(), Error>

Source§

async fn flush(&self) -> Result<(), Error>

Source§

async fn disconnect(&self) -> Result<(), Error>

Auto Trait Implementations§

§

impl<I> !Freeze for Actor<I>

§

impl<I> !RefUnwindSafe for Actor<I>

§

impl<I> Send for Actor<I>

§

impl<I> Sync for Actor<I>

§

impl<I> Unpin for Actor<I>

§

impl<I> !UnwindSafe for Actor<I>

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.