webrtc_dtls/change_cipher_spec/
mod.rs1#[cfg(test)]
2mod change_cipher_spec_test;
3
4use std::io::{Read, Write};
5
6use byteorder::{ReadBytesExt, WriteBytesExt};
7
8use super::content::*;
9use super::error::*;
10
11#[derive(Clone, PartialEq, Eq, Debug)]
21pub struct ChangeCipherSpec;
22
23impl ChangeCipherSpec {
24 pub fn content_type(&self) -> ContentType {
25 ContentType::ChangeCipherSpec
26 }
27
28 pub fn size(&self) -> usize {
29 1
30 }
31
32 pub fn marshal<W: Write>(&self, writer: &mut W) -> Result<()> {
33 writer.write_u8(0x01)?;
34
35 Ok(writer.flush()?)
36 }
37
38 pub fn unmarshal<R: Read>(reader: &mut R) -> Result<Self> {
39 let data = reader.read_u8()?;
40 if data != 0x01 {
41 return Err(Error::ErrInvalidCipherSpec);
42 }
43
44 Ok(ChangeCipherSpec {})
45 }
46}