mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-16 20:55:03 +01:00
more
This commit is contained in:
parent
08ba799d23
commit
f860714b2b
9 changed files with 64 additions and 24 deletions
|
|
@ -144,8 +144,9 @@ mod content_header_write {
|
|||
Table,
|
||||
},
|
||||
};
|
||||
use std::io::Write;
|
||||
|
||||
pub fn write_content_header(buf: &mut Vec<u8>, header: &ContentHeader) -> Result<()> {
|
||||
pub fn write_content_header<W: Write>(buf: &mut W, header: &ContentHeader) -> Result<()> {
|
||||
short(&header.class_id, buf)?;
|
||||
short(&header.weight, buf)?;
|
||||
longlong(&header.body_size, buf)?;
|
||||
|
|
@ -153,8 +154,12 @@ mod content_header_write {
|
|||
write_content_header_props(buf, &header.property_fields)
|
||||
}
|
||||
|
||||
pub fn write_content_header_props(buf: &mut Vec<u8>, header: &Table) -> Result<()> {
|
||||
pub fn write_content_header_props<W: Write>(writer: &mut W, header: &Table) -> Result<()> {
|
||||
let mut flags = 0_u16;
|
||||
// todo: don't allocate for no reason here
|
||||
let mut temp_buf = Vec::new();
|
||||
let buf = &mut temp_buf;
|
||||
|
||||
buf.extend_from_slice(&flags.to_be_bytes()); // placeholder
|
||||
|
||||
if let Some(ShortString(value)) = header.get("content-type") {
|
||||
|
|
@ -218,6 +223,8 @@ mod content_header_write {
|
|||
buf[0] = a;
|
||||
buf[1] = b;
|
||||
|
||||
writer.write_all(&temp_buf)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue