Skip to main content

tor_netdoc/types/
parse2_encode.rs

1//! Helpers for parse2 and encode
2
3use void::Void;
4
5use tor_error::Bug;
6
7/// Conversion module for `Vec<u8>` as Object with `ItemValueParseable`/`ItemValueEncodable`
8pub mod raw_data_object {
9    use super::*;
10
11    /// "Parse" the data
12    pub fn try_from(data: Vec<u8>) -> Result<Vec<u8>, Void> {
13        Ok(data)
14    }
15
16    /// "Encode" the data
17    pub fn write_object_onto(self_: &[u8], out: &mut Vec<u8>) -> Result<(), Bug> {
18        out.extend(self_);
19        Ok(())
20    }
21}