pub struct ImportEngine<'a> { /* private fields */ }Expand description
Import workflow engine.
Implementations§
Source§impl<'a> ImportEngine<'a>
impl<'a> ImportEngine<'a>
Sourcepub async fn notes(
&self,
notes: &[Note],
on_duplicate: OnDuplicate,
) -> Result<ImportReport>
pub async fn notes( &self, notes: &[Note], on_duplicate: OnDuplicate, ) -> Result<ImportReport>
Import notes with duplicate handling.
Validates notes, checks for duplicates, and imports in batches.
§Arguments
notes- Notes to importon_duplicate- Strategy for handling duplicates
§Example
let engine = Engine::new();
let notes = vec![
NoteBuilder::new("Default", "Basic")
.field("Front", "Q1")
.field("Back", "A1")
.build(),
];
let report = engine.import().notes(¬es, OnDuplicate::Skip).await?;Sourcepub async fn validate(&self, notes: &[Note]) -> Result<Vec<ValidationResult>>
pub async fn validate(&self, notes: &[Note]) -> Result<Vec<ValidationResult>>
Validate notes before import without actually importing.
Returns detailed validation results for each note.
Sourcepub async fn smart_add(
&self,
note: &Note,
options: SmartAddOptions,
) -> Result<SmartAddResult>
pub async fn smart_add( &self, note: &Note, options: SmartAddOptions, ) -> Result<SmartAddResult>
Smart add a single note with duplicate checking and tag suggestions.
Combines validation, duplicate detection, and tag suggestions into a single atomic operation.
§Arguments
note- Note to addoptions- Options controlling duplicate handling and tag suggestions
§Example
let engine = Engine::new();
let note = NoteBuilder::new("Japanese", "Basic")
.field("Front", "hello")
.field("Back", "world")
.build();
let result = engine.import().smart_add(¬e, SmartAddOptions::default()).await?;
match result.status {
ankit_engine::import::SmartAddStatus::Added => {
println!("Added note: {:?}", result.note_id);
}
ankit_engine::import::SmartAddStatus::RejectedDuplicate { existing_id } => {
println!("Duplicate of note {}", existing_id);
}
_ => {}
}
if !result.suggested_tags.is_empty() {
println!("Suggested tags: {:?}", result.suggested_tags);
}Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for ImportEngine<'a>
impl<'a> !RefUnwindSafe for ImportEngine<'a>
impl<'a> Send for ImportEngine<'a>
impl<'a> Sync for ImportEngine<'a>
impl<'a> Unpin for ImportEngine<'a>
impl<'a> !UnwindSafe for ImportEngine<'a>
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