#[cfg(test)]
mod renegotiation_info_test;
use super::*;
use crate::error::Error::ErrInvalidPacketLength;
const RENEGOTIATION_INFO_HEADER_SIZE: usize = 5;
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ExtensionRenegotiationInfo {
pub(crate) renegotiated_connection: u8,
}
impl ExtensionRenegotiationInfo {
pub fn extension_value(&self) -> ExtensionValue {
ExtensionValue::RenegotiationInfo
}
pub fn size(&self) -> usize {
3
}
pub fn marshal<W: Write>(&self, writer: &mut W) -> Result<()> {
writer.write_u16::<BigEndian>(1)?; writer.write_u8(self.renegotiated_connection)?;
Ok(writer.flush()?)
}
pub fn unmarshal<R: Read>(reader: &mut R) -> Result<Self> {
let l = reader.read_u16::<BigEndian>()?; if l != 1 {
return Err(ErrInvalidPacketLength);
}
let renegotiated_connection = reader.read_u8()?;
Ok(ExtensionRenegotiationInfo {
renegotiated_connection,
})
}
}