hadoop_common/io/
text.rs

1#[derive(Debug)]
2pub struct Text {
3    _bytes: Vec<u8>,
4    _length: i32,
5}
6
7impl Text {
8    /// Converts the provided String to bytes using the
9    /// UTF-8 encoding. If `replace` is true, then
10    /// malformed input is replaced with the
11    /// substitution character, which is U+FFFD. Otherwise the
12    /// method throws a MalformedInputException.
13    fn encode(s: &str, _replace: bool) -> &[u8] {
14        // TODO: handle malformed input
15
16        s.as_bytes()
17    }
18}
19
20impl From<String> for Text {
21    fn from(s: String) -> Self {
22        let bb = Self::encode(&s, true);
23        Self {
24            _bytes: bb.into(),
25            _length: bb.len() as i32,
26        }
27    }
28}