Yield Strings from TextWriter::encode*

This commit is contained in:
Tony Garnock-Jones 2021-08-05 14:28:19 +02:00
parent 87946abb63
commit 661d96780d
1 changed files with 3 additions and 3 deletions

View File

@ -37,13 +37,13 @@ impl TextWriter<&mut Vec<u8>> {
pub fn encode<D: Embeddable, N: NestedValue<D>, Enc: DomainEncode<D>>(
enc: &mut Enc,
v: &N,
) -> io::Result<Vec<u8>> {
) -> io::Result<String> {
let mut buf: Vec<u8> = Vec::new();
TextWriter::new(&mut buf).write(enc, v)?;
Ok(buf)
Ok(String::from_utf8(buf).expect("valid UTF-8 from TextWriter"))
}
pub fn encode_iovalue(v: &IOValue) -> io::Result<Vec<u8>> {
pub fn encode_iovalue(v: &IOValue) -> io::Result<String> {
Self::encode(&mut IOValueDomainCodec, v)
}
}