[−][src]Struct udp_server::Peer
Peer 对象 用来标识client socket_id 标识 所在哪个UDPContent,一般只在头一次接收到数据的时候设置 一般用来所在Peer位置,linux 服务器上启用了 reuse_port 所以后续收到数据包不一定来自于此 所在哪个UDPContent 而windows上只有一个socket,所以始终只有1个
token
你可以自定义放一些和用户有关的数据,这样的话方便你对用户进行区别,已提取用户逻辑数据
Fields
socket_id: usize
addr: SocketAddr
token: Option<RefCell<T>>
udp_sock: Weak<Mutex<SendHalf>>
Implementations
impl<T: Send> Peer<T>
[src]
pub async fn send<'_, '_>(
&'_ mut self,
data: &'_ [u8]
) -> Result<usize, Box<dyn Error>>
[src]
&'_ mut self,
data: &'_ [u8]
) -> Result<usize, Box<dyn Error>>
Send 发送数据包 作为最基本的函数之一,它采用了tokio的async send_to 首先,他会去弱指针里面拿到强指针,如果没有他会爆错
Trait Implementations
Auto Trait Implementations
impl<T> !RefUnwindSafe for Peer<T>
impl<T> Send for Peer<T>
impl<T> !Sync for Peer<T>
impl<T> Unpin for Peer<T> where
T: Unpin,
T: Unpin,
impl<T> !UnwindSafe for Peer<T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,