pub struct FilePatch {
filename: String,
header_row: Option<Vec<String>>,
replacement_content: Option<String>,
to_delete: IndexSet<Vec<String>>,
to_add: IndexSet<Vec<String>>,
}Expand description
Structure to hold patches for a model csv file.
Fields§
§filename: StringThe file that this patch applies to (e.g. “agents.csv”)
header_row: Option<Vec<String>>The header row (optional). If None, the header is not checked against base files.
replacement_content: Option<String>Full replacement content for this file (optional)
to_delete: IndexSet<Vec<String>>Rows to delete (each row is a vector of fields)
to_add: IndexSet<Vec<String>>Rows to add (each row is a vector of fields)
Implementations§
Source§impl FilePatch
impl FilePatch
Sourcepub fn with_header(self, header: impl Into<String>) -> Self
pub fn with_header(self, header: impl Into<String>) -> Self
Set the header row for this patch (header should be a comma-joined string, e.g. “a,b,c”).
Sourcepub fn with_replacement(self, lines: &[&str]) -> Self
pub fn with_replacement(self, lines: &[&str]) -> Self
Set full replacement content for this file from a slice of lines.
Each line is joined with newlines, and a trailing newline is added.
All lines must have the same number of columns (commas).
Example: with_replacement(&["header1,header2", "value1,value2"])
Sourcepub fn with_addition(self, row: impl Into<String>) -> Self
pub fn with_addition(self, row: impl Into<String>) -> Self
Add a row to the patch (row should be a comma-joined string, e.g. “a,b,c”).
Sourcepub fn with_deletion(self, row: impl Into<String>) -> Self
pub fn with_deletion(self, row: impl Into<String>) -> Self
Mark a row for deletion from the base (row should be a comma-joined string, e.g. “a,b,c”).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FilePatch
impl RefUnwindSafe for FilePatch
impl Send for FilePatch
impl Sync for FilePatch
impl Unpin for FilePatch
impl UnwindSafe for FilePatch
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
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>
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>
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