Looking at the documentation,我åªèƒ½æ‰¾åˆ°ä¸€ç§æ–¹æ³•æ¥è¿”回通过UDPå‘é€çš„内容的大å°ï¼š
 Â从套接å—接收数æ®ã€‚æˆåŠŸæ—¶ï¼Œè¿”回读å–çš„å—节数和数æ®æ¥è‡ªçš„地å€ã€‚
ç›®å‰æœ‰è¾“出内容的方法å—?
ç”案 0 :(得分:2)
fn recv_from(&self, buf: &mut [u8]) -> Result<(usize, SocketAddr)>
æ•°æ®è¢«è¯»å…¥buf
çš„å¼€å¤´ã€‚å› æ¤ï¼Œè¯»å–çš„æ•°æ®å¯ä»¥åƒ&[u8]
é‚£æ ·è®¿é—®ï¼š
match socket.recv_from(buf) {
Ok((bytes_read, _)) => Some(&buf[0..bytes_read]),
Err(_) => None,
}