Struct UDSMsgServer

Source
pub struct UDSMsgServer<T> {
    pub path_name: String,
    pub name: String,
    pub connections: Arc<Mutex<HashMap<String, Sender<Option<T>>>>>,
}

Fields§

§path_name: String§name: String§connections: Arc<Mutex<HashMap<String, Sender<Option<T>>>>>

Implementations§

Source§

impl<T> UDSMsgServer<T>
where T: DeserializeOwned + Serialize + Send + 'static + Clone,

Source

pub fn new(path_name: &str, server_name: &str) -> UDSMsgServer<T>

addr is socket address. like: 127.0.0.1:6666. name is the server’s name, to identity which server it is.

Source

pub fn start_server<F>( &self, first_msg: T, process_function: F, ) -> Box<dyn Future<Item = (), Error = ()> + Send + 'static>
where F: FnMut(String, T) -> Vec<(String, T)> + Send + Sync + 'static + Clone,

first_msg is the first message that server send to the client which just connect to server. process_fuction receive a tuple of <client_name, message>, and return a series of tuple of (client_name,message) indicating which message will be sent to which client. Note that if you want to send a message to current client, you should set client_name as a string with 0 length, i.e. “”

Trait Implementations§

Source§

impl<T: Debug> Debug for UDSMsgServer<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for UDSMsgServer<T>

§

impl<T> RefUnwindSafe for UDSMsgServer<T>

§

impl<T> Send for UDSMsgServer<T>
where T: Send,

§

impl<T> Sync for UDSMsgServer<T>
where T: Send,

§

impl<T> Unpin for UDSMsgServer<T>

§

impl<T> UnwindSafe for UDSMsgServer<T>

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.