pub trait TypeLoader: Send + Sync {
// Required methods
fn load_from_xml(
&self,
node_id: &NodeId,
stream: &mut XmlStreamReader<&mut dyn Read>,
ctx: &Context<'_>,
name: &str,
) -> Option<EncodingResult<Box<dyn DynEncodable>>>;
fn load_from_json(
&self,
node_id: &NodeId,
stream: &mut JsonStreamReader<&mut dyn Read>,
ctx: &Context<'_>,
) -> Option<EncodingResult<Box<dyn DynEncodable>>>;
fn load_from_binary(
&self,
node_id: &NodeId,
stream: &mut dyn Read,
ctx: &Context<'_>,
length: Option<usize>,
) -> Option<EncodingResult<Box<dyn DynEncodable>>>;
// Provided method
fn priority(&self) -> TypeLoaderPriority { ... }
}Expand description
Trait for a collection of types.
Each method in this trait should try to decode the passed stream/body
into a DynEncodable, and return None if the node_id does not match
any variant. It should only return an error if the node_id is a match,
but decoding failed.
Required Methods§
Sourcefn load_from_xml(
&self,
node_id: &NodeId,
stream: &mut XmlStreamReader<&mut dyn Read>,
ctx: &Context<'_>,
name: &str,
) -> Option<EncodingResult<Box<dyn DynEncodable>>>
fn load_from_xml( &self, node_id: &NodeId, stream: &mut XmlStreamReader<&mut dyn Read>, ctx: &Context<'_>, name: &str, ) -> Option<EncodingResult<Box<dyn DynEncodable>>>
Load the type given by node_id from XML by trying each
registered type loader until one returns Some.
Sourcefn load_from_json(
&self,
node_id: &NodeId,
stream: &mut JsonStreamReader<&mut dyn Read>,
ctx: &Context<'_>,
) -> Option<EncodingResult<Box<dyn DynEncodable>>>
fn load_from_json( &self, node_id: &NodeId, stream: &mut JsonStreamReader<&mut dyn Read>, ctx: &Context<'_>, ) -> Option<EncodingResult<Box<dyn DynEncodable>>>
Load the type given by node_id from JSON by trying each
registered type loader until one returns Some.
Sourcefn load_from_binary(
&self,
node_id: &NodeId,
stream: &mut dyn Read,
ctx: &Context<'_>,
length: Option<usize>,
) -> Option<EncodingResult<Box<dyn DynEncodable>>>
fn load_from_binary( &self, node_id: &NodeId, stream: &mut dyn Read, ctx: &Context<'_>, length: Option<usize>, ) -> Option<EncodingResult<Box<dyn DynEncodable>>>
Load the type given by node_id from Binary by trying each
registered type loader until one returns Some.
Provided Methods§
Sourcefn priority(&self) -> TypeLoaderPriority
fn priority(&self) -> TypeLoaderPriority
Get the priority of this type loader.