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
38
39
40
41
42
use std::io;
use std::io::{BufRead, BufReader};
pub trait TextIonDataSource {
type TextSource: BufRead;
fn to_text_ion_data_source(self) -> Self::TextSource;
}
impl TextIonDataSource for String {
type TextSource = io::Cursor<Self>;
fn to_text_ion_data_source(self) -> Self::TextSource {
io::Cursor::new(self)
}
}
impl<'a> TextIonDataSource for &'a str {
type TextSource = io::Cursor<Self>;
fn to_text_ion_data_source(self) -> Self::TextSource {
io::Cursor::new(self)
}
}
impl<'a> TextIonDataSource for &'a &[u8] {
type TextSource = io::Cursor<Self>;
fn to_text_ion_data_source(self) -> Self::TextSource {
io::Cursor::new(self)
}
}
impl<T: io::Read> TextIonDataSource for BufReader<T> {
type TextSource = Self;
fn to_text_ion_data_source(self) -> Self::TextSource {
self
}
}