use std::io::{Read, Write}; use util::Error; use super::content::*; // Application data messages are carried by the record layer and are // fragmented, compressed, and encrypted based on the current connection // state. The messages are treated as transparent data to the record // layer. // https://tools.ietf.org/html/rfc5246#section-10 #[derive(Clone, PartialEq, Debug)] pub struct ApplicationData { data: Vec, } impl ApplicationData { pub fn content_type(&self) -> ContentType { ContentType::ApplicationData } pub fn marshal(&self, writer: &mut W) -> Result<(), Error> { writer.write_all(&self.data)?; Ok(()) } pub fn unmarshal(reader: &mut R) -> Result { let mut data: Vec = vec![]; reader.read_to_end(&mut data)?; Ok(ApplicationData { data }) } }