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>
impl<T> UDSMsgServer<T>
Sourcepub fn new(path_name: &str, server_name: &str) -> UDSMsgServer<T>
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.
Sourcepub fn start_server<F>(
&self,
first_msg: T,
process_function: F,
) -> Box<dyn Future<Item = (), Error = ()> + Send + 'static>
pub fn start_server<F>( &self, first_msg: T, process_function: F, ) -> Box<dyn Future<Item = (), Error = ()> + Send + 'static>
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more