pub struct SyncStream { /* private fields */ }
Expand description
the TcpStream version of the artifice network, implements encryption automatically in its implementation of std::io::Write, and std::io::Read
Implementations§
Source§impl SyncStream
impl SyncStream
Sourcepub fn recv(&mut self, outbuf: &mut Vec<u8>) -> Result<usize, NetworkError>
pub fn recv(&mut self, outbuf: &mut Vec<u8>) -> Result<usize, NetworkError>
implented in place of std::io::Read, because reading to empty vec fails
Examples found in repository?
examples/client.rs (line 18)
4fn main() {
5 // this function is for testing only
6 let (mut peer, config) = test_config();
7 peer.set_socket_addr(SocketAddr::new(
8 IpAddr::V4(Ipv4Addr::new(10, 0, 0, 81)),
9 6464,
10 ));
11 let host = SyncHost::client_only(&config).unwrap();
12 let mut stream = host.connect(peer).unwrap();
13 println!("connected");
14 let mut buffer = Vec::new();
15 println!("about to read from sream");
16 println!(
17 "got {} bytes from server",
18 stream.recv(&mut buffer).unwrap()
19 );
20 println!("read from stream");
21 let string = String::from_utf8(buffer).unwrap();
22 println!("got message: {} from server", string);
23}
Trait Implementations§
Source§impl Debug for SyncStream
impl Debug for SyncStream
Source§impl SyncDataStream for SyncStream
impl SyncDataStream for SyncStream
type NetStream = TcpStream
type Error = NetworkError
fn new( stream: Self::NetStream, header: StreamHeader, remote_addr: SocketAddr, ) -> Result<Self, Self::Error>
fn socket_addr(&self) -> SocketAddr
fn header(&self) -> &StreamHeader
fn addr(&self) -> IpAddr
Auto Trait Implementations§
impl Freeze for SyncStream
impl RefUnwindSafe for SyncStream
impl Send for SyncStream
impl Sync for SyncStream
impl Unpin for SyncStream
impl UnwindSafe for SyncStream
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