39 lines
1.0 KiB
Rust
39 lines
1.0 KiB
Rust
use super::BinarySource;
|
|
use super::Embeddable;
|
|
use super::IOResult;
|
|
use super::IOValue;
|
|
use super::Reader;
|
|
use super::packed::PackedReader;
|
|
|
|
pub trait DomainDecode<D: Embeddable> {
|
|
fn decode_embedded<'de, 'src, S: BinarySource<'de>>(
|
|
&mut self,
|
|
src: &'src mut S,
|
|
read_annotations: bool,
|
|
) -> IOResult<D>;
|
|
}
|
|
|
|
pub struct IOValueDomainDecode;
|
|
|
|
impl DomainDecode<IOValue> for IOValueDomainDecode {
|
|
fn decode_embedded<'de, 'src, S: BinarySource<'de>>(
|
|
&mut self,
|
|
src: &'src mut S,
|
|
read_annotations: bool,
|
|
) -> IOResult<IOValue> {
|
|
PackedReader::new(src, IOValueDomainDecode).demand_next(read_annotations)
|
|
}
|
|
}
|
|
|
|
pub struct NoEmbeddedDomainDecode;
|
|
|
|
impl<D: Embeddable> DomainDecode<D> for NoEmbeddedDomainDecode {
|
|
fn decode_embedded<'de, 'src, S: BinarySource<'de>>(
|
|
&mut self,
|
|
_src: &'src mut S,
|
|
_read_annotations: bool,
|
|
) -> IOResult<D> {
|
|
Err(std::io::Error::new(std::io::ErrorKind::Unsupported, "Embedded values not supported here"))
|
|
}
|
|
}
|