pub struct ImportConfig { /* private fields */ }Expand description
Import configuration
§Examples
use reinhardt_admin::core::{ImportConfig, ImportFormat};
let config = ImportConfig::new("User", ImportFormat::CSV)
.with_field_mapping("username", "login")
.skip_duplicates(true)
.update_existing(false);
assert_eq!(config.model_name(), "User");Implementations§
Source§impl ImportConfig
impl ImportConfig
Sourcepub fn new(model_name: impl Into<String>, format: ImportFormat) -> Self
pub fn new(model_name: impl Into<String>, format: ImportFormat) -> Self
Create a new import configuration
Sourcepub fn model_name(&self) -> &str
pub fn model_name(&self) -> &str
Get model name
Sourcepub fn format(&self) -> ImportFormat
pub fn format(&self) -> ImportFormat
Get import format
Sourcepub fn with_field_mapping(
self,
import_field: impl Into<String>,
model_field: impl Into<String>,
) -> Self
pub fn with_field_mapping( self, import_field: impl Into<String>, model_field: impl Into<String>, ) -> Self
Add field mapping
Sourcepub fn field_mappings(&self) -> &HashMap<String, String>
pub fn field_mappings(&self) -> &HashMap<String, String>
Get field mappings
Sourcepub fn map_field<'a>(&'a self, import_field: &'a str) -> &'a str
pub fn map_field<'a>(&'a self, import_field: &'a str) -> &'a str
Map import field to model field
Sourcepub fn skip_field(self, field: impl Into<String>) -> Self
pub fn skip_field(self, field: impl Into<String>) -> Self
Add field to skip
Sourcepub fn skip_fields(&self) -> &[String]
pub fn skip_fields(&self) -> &[String]
Get skip fields
Sourcepub fn skip_duplicates(self, skip: bool) -> Self
pub fn skip_duplicates(self, skip: bool) -> Self
Set whether to skip duplicates
Sourcepub fn should_skip_duplicates(&self) -> bool
pub fn should_skip_duplicates(&self) -> bool
Check if duplicates should be skipped
Sourcepub fn update_existing(self, update: bool) -> Self
pub fn update_existing(self, update: bool) -> Self
Set whether to update existing records
Sourcepub fn should_update_existing(&self) -> bool
pub fn should_update_existing(&self) -> bool
Check if existing records should be updated
Sourcepub fn with_key_field(self, field: impl Into<String>) -> Self
pub fn with_key_field(self, field: impl Into<String>) -> Self
Set key field for duplicate detection
Sourcepub fn with_max_records(self, max: usize) -> Self
pub fn with_max_records(self, max: usize) -> Self
Set maximum records to import
Sourcepub fn max_records(&self) -> Option<usize>
pub fn max_records(&self) -> Option<usize>
Get maximum records
Sourcepub fn with_skip_header(self, skip: bool) -> Self
pub fn with_skip_header(self, skip: bool) -> Self
Set whether to skip header row
Sourcepub fn should_skip_header(&self) -> bool
pub fn should_skip_header(&self) -> bool
Check if header should be skipped
Sourcepub fn with_validation(self, validate: bool) -> Self
pub fn with_validation(self, validate: bool) -> Self
Set whether to validate before import
Sourcepub fn should_validate(&self) -> bool
pub fn should_validate(&self) -> bool
Check if validation should be performed
Trait Implementations§
Source§impl Clone for ImportConfig
impl Clone for ImportConfig
Source§fn clone(&self) -> ImportConfig
fn clone(&self) -> ImportConfig
Returns a duplicate 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 moreAuto Trait Implementations§
impl Freeze for ImportConfig
impl RefUnwindSafe for ImportConfig
impl Send for ImportConfig
impl Sync for ImportConfig
impl Unpin for ImportConfig
impl UnwindSafe for ImportConfig
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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