Skip to main content

flash_lso/amf3/
custom_encoder.rs

1use crate::amf3::read::AMF3Decoder;
2
3use crate::amf3::write::AMF3Encoder;
4
5use crate::types::Element;
6use crate::types::*;
7
8use crate::nom_utils::AMFResult;
9
10/// A trait to define encoding for custom types for use with Externalized objects
11pub trait CustomEncoder {
12    /// This should implement the encoding of a given set of external elements for the given class definition
13    /// Access to the AMF3Encoder is given to allow access to caches
14    /// This implements the encoding side of externalized type support
15    fn encode(
16        &self,
17        elements: &[Element],
18        class_def: &Option<ClassDefinition>,
19        encoder: &AMF3Encoder,
20    ) -> Vec<u8>;
21}
22
23/// A trait to define decoding for custom types for use with Externalized objects
24pub trait CustomDecoder {
25    /// This should implement the decoding of a given set of external elements
26    /// Access to the AMF3Decoder is given to allow access to caches
27    /// This implements the decoding side of externalized type support
28    fn decode<'a>(&self, i: &'a [u8], dec: &mut AMF3Decoder) -> AMFResult<'a, Vec<Element>>;
29}