Serialize to exactly [`PREAMBLE_SIZE`] bytes.
(&self)
| 88 | |
| 89 | /// Serialize to exactly [`PREAMBLE_SIZE`] bytes. |
| 90 | pub fn to_bytes(&self) -> [u8; PREAMBLE_SIZE] { |
| 91 | let mut buf = [0u8; PREAMBLE_SIZE]; |
| 92 | buf[0..4].copy_from_slice(&self.magic); |
| 93 | buf[4..6].copy_from_slice(&self.version.to_le_bytes()); |
| 94 | buf[6] = self.cipher_alg; |
| 95 | buf[7] = self.kid; |
| 96 | buf[8..12].copy_from_slice(&self.epoch); |
| 97 | // buf[12..16] stays zero (reserved) |
| 98 | buf |
| 99 | } |
| 100 | |
| 101 | /// Deserialize and validate a preamble, checking magic and version. |
| 102 | /// |
no outgoing calls