Trait tencent_scf::convert::FromReader [−][src]
Trait for conversion from raw incoming invocation to event type
Custom event should implement this trait so that the runtime can deserialize the incoming invocation into the desired event.
Implement the Trait
One needs to provide a method that can consume a raw byte reader into the desired type.
use tencent_scf::convert::FromReader; // Our custom event type struct Event(String); // Simply read everything from the reader. impl FromReader for Event { type Error = std::io::Error; fn from_reader<Reader: std::io::Read + Send>( mut reader: Reader, ) -> Result<Self, Self::Error> { let mut buf = String::new(); reader.read_to_string(&mut buf)?; Ok(Event(buf)) } }
Associated Types
type Error
[src]
Possible error during the conversion. std::fmt::Display
is all the runtime needs.
Required methods
fn from_reader<Reader: Read + Send>(reader: Reader) -> Result<Self, Self::Error>
[src]
Consume the reader
and produce the deserialized output
Implementations on Foreign Types
impl FromReader for Vec<u8>
[src]
Auto deserialization into a byte array.
type Error = Error
fn from_reader<Reader: Read + Send>(
mut reader: Reader
) -> Result<Self, Self::Error>
[src]
mut reader: Reader
) -> Result<Self, Self::Error>
impl FromReader for String
[src]
Auto deserialization into a string.
type Error = Error
fn from_reader<Reader: Read + Send>(
mut reader: Reader
) -> Result<Self, Self::Error>
[src]
mut reader: Reader
) -> Result<Self, Self::Error>
Implementors
impl<T> FromReader for T where
T: DeserializeOwned + AsJson,
[src]
T: DeserializeOwned + AsJson,
Auto deserilization for types that are serde::Deserialize
and marked as AsJson
.