pub struct ImportRun { /* private fields */ }Expand description
What one import run knows: each notes file it has touched, read from disk once and kept in step with what the run has stored since, in a dry run too. That is what makes the lines of one run be judged against each other, and a dry run report what the real run then does.
A run is a dry run or a real one from ImportRun::new to its end, so
what a dry run remembers as stored can never be taken for stored by a
real one: a preview and the import after it are two runs.
End a run with ImportRun::finish, on an early stop too: nothing a
real run stored is durable before it returns Ok. The compiler cannot
tell a run that was dropped on an early return from one that was
finished (#[must_use] only catches a run that is never bound). So a
real run that is dropped unfinished syncs what it appended as it goes,
and logs it if that fails; only the caller’s chance to see the error is
lost.
Implementations§
Source§impl ImportRun
impl ImportRun
Sourcepub fn new(dry_run: bool) -> ImportRun
pub fn new(dry_run: bool) -> ImportRun
A run that writes (dry_run false), or one that writes, creates and
syncs nothing and gives the outcomes the real run would give from the
same files.
pub fn is_dry_run(&self) -> bool
Sourcepub fn finish(self) -> Result<Vec<PathBuf>, MemoryError>
pub fn finish(self) -> Result<Vec<PathBuf>, MemoryError>
End the run: sync every file it appended to, then the directory of
each. An import’s appends are not synced one by one, so nothing the
run stored is durable until this returns Ok; call it when the run
stops early too. Returns the files synced, sorted. A dry run has
none.
Every file and every directory is tried, also after one failed.
An error is MemoryError::WrittenUnconfirmed for the first sync
that failed, naming its file: the lines the run reported as stored
are in their files, and that sync failed.
Trait Implementations§
Auto Trait Implementations§
impl Forget for ImportRun
impl Freeze for ImportRun
impl Move for ImportRun
impl RefUnwindSafe for ImportRun
impl Send for ImportRun
impl Sync for ImportRun
impl Unpin for ImportRun
impl UnsafeUnpin for ImportRun
impl UnwindSafe for ImportRun
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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> ⓘ
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