Struct CbskClient

Source
pub struct CbskClient {
    pub header: Arc<Vec<u8>>,
    /* private fields */
}
Expand description

cbsk client

Fields§

§header: Arc<Vec<u8>>

cbsk header

Implementations§

Source§

impl CbskClient

custom method

Source

pub fn new<C: CbskClientCallBack>( cb: Arc<C>, addr: SocketAddr, buf_len: usize, ) -> Self

new cbsk client
if the tcp connection is disconnected, it will reconnect after 3 seconds

Source

pub fn new_with_tcp_config<C: CbskClientCallBack>( cb: Arc<C>, conf: Arc<TcpClientConfig>, buf_len: usize, ) -> Self

use tcp client config create cbsk client

Source

pub fn new_with_header<C: CbskClientCallBack>( cb: Arc<C>, addr: SocketAddr, header: Vec<u8>, buf_len: usize, ) -> Self

custom header create cbsk client

Source

pub fn new_with_htc<C: CbskClientCallBack>( cb: Arc<C>, header: Vec<u8>, conf: Arc<TcpClientConfig>, buf_len: usize, ) -> Self

htc is an abbreviation for header_tcp_config

Source

pub fn default_tcp_config(addr: SocketAddr) -> TcpClientConfig

get default tcp config

Source

pub async fn start(&self)

start cbsk client

Source

pub fn start_in_handle(&self) -> JoinHandle<()>

start cbsk client in join handle

Source

pub async fn is_connected(&self) -> bool

get has the cbsk server connection been success

Source

pub async fn stop(&self)

stop cbsk server connect
will shutdown tcp connection and will not new connection

Source

pub async fn re_conn(&self)

notify tcp to re connect
will shutdown tcp connection, if TcpClientConfig reconn is disable
will shutdown and create new tcp connection,if TcpClientConfig reconn is enable

Source

pub fn get_recv_time(&self) -> i64

the last time the data was received

Source

pub fn get_config(&self) -> Arc<TcpClientConfig>

get tcp config

Trait Implementations§

Source§

impl CbskWriteTrait for CbskClient

support write data to cbsk

Source§

fn get_log_head(&self) -> &str

get internal log name
Source§

async fn try_send_bytes(&self, bytes: Vec<u8>) -> Result<()>

try send bytes to cbsk
Source§

async fn send_text(&self, text: &str)

send text to cbsk
Source§

async fn try_send_text(&self, text: impl Into<String>) -> Result<()>

try send text to cbsk
Source§

async fn send_json(&self, json: &(impl Serialize + Sync))

send json to cbsk
Source§

async fn try_send_json(&self, json: &(impl Serialize + Sync)) -> Result<()>

try send json to cbsk
Source§

async fn send_bytes(&self, bytes: Vec<u8>)

send bytes to cbsk
Source§

impl TimeTrait for CbskClient

support time trait

Source§

fn set_recv_time(&self, time: i64)

set the last time the data was received for tcp
Source§

fn get_recv_time(&self) -> i64

get the last time the data was received for tcp
Source§

fn set_timeout_time(&self, time: i64)

set tcp last read timeout
Source§

fn get_timeout_time(&self) -> i64

get tcp last read timeout
Source§

fn set_wait_callback(&self, is_wait: bool)

set is wait callback
Source§

fn get_wait_callback(&self) -> bool

get is wait callback
Source§

fn set_ignore_once(&self, is_ignore: bool)

set ignore once time check
Source§

fn get_ignore(&self) -> bool

get ignore
Source§

fn set_now(&self)

set recv time and timeout time to now
Source§

fn set_recv_time_now(&self)

set recv time to now
Source§

fn set_timeout_time_now(&self)

set timeout time to now
Source§

fn now() -> i64

get now unix_timestamp_millis
Source§

fn wait_callback(&self)

need wait callback finish business logic
Source§

fn finish_callback(&self)

callback the business logic has been completed

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.