pub struct DiffByteRecords { /* private fields */ }
Expand description
Holds all information about the difference between two CSVs, after they have
been compared with CsvByteDiffLocal.diff
.
CSV records that are equal are not stored in this structure.
Also, keep in mind, that differences are stored unordered (with regard to the line in the CSV).
You can use DiffByteRecords.sort_by_line
to sort them in-place.
See the example on CsvByteDiffLocal
for general usage.
Implementationsยง
Sourceยงimpl DiffByteRecords
impl DiffByteRecords
pub fn headers(&self) -> &Headers
pub fn num_columns(&self) -> Option<usize>
Sourcepub fn sort_by_line(&mut self)
pub fn sort_by_line(&mut self)
Sort the underlying DiffByteRecord
s by line.
Note that comparison is done in parallel. Therefore, without calling this method, the resulting DiffByteRecord
s are out of order
after the comparison (with regard to their line in the original CSV).
pub fn sort_by_columns<E: Into<ColumnIdx>, I: IntoIterator<Item = E>>( &mut self, cols: I, ) -> Result<(), ColumnIdxError>
Sourcepub fn as_slice(&self) -> &[DiffByteRecord]
pub fn as_slice(&self) -> &[DiffByteRecord]
Return the DiffByteRecord
s as a single slice.
ยงExample
use csv_diff::{csv_diff::CsvByteDiffLocal, csv::Csv};
use std::collections::HashSet;
use std::iter::FromIterator;
// some csv data with a header, where the first column is a unique id
let csv_data_left = "id,name,kind\n\
1,lemon,fruit\n\
2,strawberry,fruit";
let csv_data_right = "id,name,kind\n\
1,lemon,fruit\n\
2,strawberry,nut\n\
3,cherry,fruit";
let csv_byte_diff = CsvByteDiffLocal::new()?;
let mut diff_byte_records = csv_byte_diff.diff(
Csv::with_reader_seek(csv_data_left.as_bytes()),
Csv::with_reader_seek(csv_data_right.as_bytes()),
)?;
let diff_byte_record_slice = diff_byte_records.as_slice();
assert_eq!(
diff_byte_record_slice.len(),
2
);
Ok(())
Sourcepub fn iter(&self) -> Iter<'_, DiffByteRecord>
pub fn iter(&self) -> Iter<'_, DiffByteRecord>
Return an iterator over the DiffByteRecord
s.
Trait Implementationsยง
Sourceยงimpl Clone for DiffByteRecords
impl Clone for DiffByteRecords
Sourceยงfn clone(&self) -> DiffByteRecords
fn clone(&self) -> DiffByteRecords
Returns a copy of the value. Read more
1.0.0 ยท Sourceยงfn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSourceยงimpl Debug for DiffByteRecords
impl Debug for DiffByteRecords
Sourceยงimpl IntoIterator for DiffByteRecords
impl IntoIterator for DiffByteRecords
Sourceยงimpl PartialEq for DiffByteRecords
impl PartialEq for DiffByteRecords
impl StructuralPartialEq for DiffByteRecords
Auto Trait Implementationsยง
impl Freeze for DiffByteRecords
impl RefUnwindSafe for DiffByteRecords
impl Send for DiffByteRecords
impl Sync for DiffByteRecords
impl Unpin for DiffByteRecords
impl UnwindSafe for DiffByteRecords
Blanket Implementationsยง
Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Sourceยงimpl<T> IntoEither for T
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more