protocol/types/
unimplemented.rs

1use crate::{hint, Parcel, Error, ErrorKind, Settings};
2use std::io::prelude::*;
3
4/// A type that does not have any protocol serialization implemented.
5///
6/// # Behaviour
7///
8/// If any unimplemented parcel is read, an error of type
9/// `UnimplementedParcel` is returned. This allows clients to
10/// handle unimplemented data gracefully.
11///
12/// If you attempt to write an unimplemented parcel, the
13/// program panics. It makes sense to do error handling on
14/// unimplemented types that are read from remote machines,
15/// but it does not make sense to allow undefined data to be sent.
16#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
17pub struct Unimplemented;
18
19impl Parcel for Unimplemented
20{
21    const TYPE_NAME: &'static str = "Unimplemented";
22
23    fn read_field(_: &mut dyn Read,
24                  _: &Settings,
25                  _: &mut hint::Hints) -> Result<Self, Error> {
26        Err(ErrorKind::UnimplementedParcel(Self::TYPE_NAME).into())
27    }
28
29    fn write_field(&self,
30                   _: &mut dyn Write,
31                   _: &Settings,
32                   _: &mut hint::Hints) -> Result<(), Error> {
33        unimplemented!();
34    }
35}
36