pub struct Tcp { /* private fields */ }
Expand description
Tcp 链接的一层封装。
Implementations§
source§impl Tcp
impl Tcp
sourcepub fn new_with_ip(ip: &SocketAddr) -> Result<Self>
pub fn new_with_ip(ip: &SocketAddr) -> Result<Self>
已发送三个测试包
sourcepub fn send_recv(&mut self, send: &[u8]) -> Result<(usize, usize)>
pub fn send_recv(&mut self, send: &[u8]) -> Result<(usize, usize)>
发送并接收字节。需要对接收的字节进行解析(参考 Tdx::parse
的实现)。
方法返回发送和读取的字节数。
注意是读取而不是接收的字节数。 由于每次接收先读取 16 字节,所以返回的元组中,第二个数字应为 16。
pub fn into_inner(self) -> (TcpStream, BufTcp, [u8; 16])
pub fn get_ref(&self) -> (&TcpStream, &BufTcp, &[u8])
pub fn get_ref_recv(&self) -> &[u8] ⓘ
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Tcp
impl RefUnwindSafe for Tcp
impl Send for Tcp
impl Sync for Tcp
impl Unpin for Tcp
impl UnwindSafe for Tcp
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