MCPcopy Create free account
hub / github.com/devashishdxt/cli-table / try_from

Method try_from

cli-table/src/csv.rs:10–26  ·  view source on GitHub ↗
(reader: &mut Reader<R>)

Source from the content-addressed store, hash-verified

8 type Error = Error;
9
10 fn try_from(reader: &mut Reader<R>) -> Result<Self, Self::Error> {
11 let records = reader.records();
12 let rows = records
13 .map(|record| Ok(row(&record?)))
14 .collect::<Result<Vec<RowStruct>, Error>>()?;
15
16 let table = if reader.has_headers() {
17 let headers = reader.headers()?;
18 let title: RowStruct = title(headers);
19
20 rows.table().title(title)
21 } else {
22 rows.table()
23 };
24
25 Ok(table)
26 }
27}
28
29fn row(record: &StringRecord) -> RowStruct {

Callers

nothing calls this directly

Calls 4

rowFunction · 0.85
titleFunction · 0.85
tableMethod · 0.80
titleMethod · 0.45

Tested by

no test coverage detected