1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use super::RawBlob;
use crate::io::{Decode, DecodeError, Encode};
use crate::visit::Visit;
impl Encode for str {
fn encode(&self, w: &mut impl std::io::Write) -> std::io::Result<()> {
RawBlob { contents: self }.encode(w)
}
}
impl Encode for String {
fn encode(&self, w: &mut impl std::io::Write) -> std::io::Result<()> {
self.as_str().encode(w)
}
}
impl Decode for String {
fn decode(r: &mut impl std::io::Read) -> Result<Self, DecodeError> {
Ok(String::from_utf8(RawBlob::decode(r)?.contents)?)
}
}
impl Visit for String {}