ios_core/proto/lockdown.rs
1/// Lockdown protocol frame: 4 bytes big-endian length prefix + plist payload.
2pub struct LockdownFrame;
3
4impl LockdownFrame {
5 pub const HEADER_SIZE: usize = 4;
6
7 /// Encode a plist payload with the 4-byte BE length prefix.
8 pub fn encode(payload: &[u8]) -> Vec<u8> {
9 let mut out = Vec::with_capacity(Self::HEADER_SIZE + payload.len());
10 out.extend_from_slice(&(payload.len() as u32).to_be_bytes());
11 out.extend_from_slice(payload);
12 out
13 }
14
15 /// Decode the length from the first 4 bytes (big-endian).
16 pub fn decode_length(header: &[u8; 4]) -> u32 {
17 u32::from_be_bytes(*header)
18 }
19}