kplib 0.19.0

Hardened KDBX database file parser
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use std::io::Write;

use byteorder::{LittleEndian, WriteBytesExt};

/// Extension trait to write a length-tagged field
pub trait WriteLengthTaggedExt: Write {
	fn write_with_len(&mut self, data: &[u8]) -> Result<(), std::io::Error> {
		self.write_u32::<LittleEndian>(data.len() as u32)?;
		self.write_all(data)?;
		Ok(())
	}
}

impl<W: Write + ?Sized> WriteLengthTaggedExt for W {}