use crate::{Error, Marker, WriteBuffer};

/// Encode a boolean value.
pub fn write_bool(buf: &mut WriteBuffer, value: bool) -> Result<Marker, Error> {
    let marker = Marker::Bool { value };
    buf.write(1, |buf| {
        // Safety: 1 byte available in buf.
        unsafe { *buf.as_mut_ptr() = marker.encoding() }
    })?;

    Ok(marker)
}
