Skip to content

Commit

Permalink
Add RowFormatter to record public API
Browse files Browse the repository at this point in the history
  • Loading branch information
FabioBatSilva committed Jul 6, 2022
1 parent 2309157 commit 1f21308
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
17 changes: 17 additions & 0 deletions parquet/src/record/api.rs
Expand Up @@ -134,6 +134,23 @@ pub trait RowAccessor {
}

/// Trait for formating fields within a Row.
///
/// # Examples
///
/// ```
/// use std::fs::File;
/// use std::path::Path;
/// use parquet::record::Row;
/// use parquet::record::RowFormatter;
/// use parquet::file::reader::{FileReader, SerializedFileReader};
///
/// if let Ok(file) = File::open(&Path::new("test.parquet")) {
/// let reader = SerializedFileReader::new(file).unwrap();
/// let row = reader.get_row_iter(None).unwrap().next().unwrap();
/// println!("column 0: {}, column 1: {}", row.fmt(0), row.fmt(1));
/// }
/// ```
///
pub trait RowFormatter {
fn fmt(&self, i: usize) -> &dyn fmt::Display;
}
Expand Down
5 changes: 4 additions & 1 deletion parquet/src/record/mod.rs
Expand Up @@ -23,6 +23,9 @@ mod record_writer;
mod triplet;

pub use self::{
api::{Field, List, ListAccessor, Map, MapAccessor, Row, RowAccessor, RowColumnIter},
api::{
Field, List, ListAccessor, Map, MapAccessor, Row, RowAccessor, RowColumnIter,
RowFormatter,
},
record_writer::RecordWriter,
};

0 comments on commit 1f21308

Please sign in to comment.