pub fn write_all<ErrType, W: CustomWrite<ErrType>>(
    writer: &mut W,
    buf: &[u8]
) -> Result<(), ErrType>