pub trait ToraRead {
// Required method
fn reads<T>(&mut self) -> Result<T>
where T: FromReader;
}Expand description
An extension upon the standard Read implementation.
use std::io;
use std::net::TcpStream;
use tora::read::ToraRead;
fn main() -> io::Result<()> {
let mut stream = TcpStream::connect("127.0.0.1:12345")?;
let message = stream.reads::<i32>()?;
println!("{}", message);
Ok(())
}Required Methods§
Sourcefn reads<T>(&mut self) -> Result<T>where
T: FromReader,
fn reads<T>(&mut self) -> Result<T>where
T: FromReader,
Try to read and deserialize a type from this reader.
use std::io;
use std::net::TcpStream;
use tora::read::ToraRead;
fn main() -> io::Result<()> {
let mut stream = TcpStream::connect("127.0.0.1:12345")?;
let date = stream.reads::<u16>()?;
let employees: Vec<String> = stream.reads()?;
println!("{date}, {employees:?}");
Ok(())
}Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.