pub struct UsnJournal {
handle: OwnedHandle,
pub journal_id: u64,
pub next_usn: i64,
}Expand description
An open USN journal positioned for tailing: the volume handle plus the current replay cursor.
Fields§
§handle: OwnedHandle§journal_id: u64The journal’s identity (UsnJournalID); changes if NTFS recreates it,
which invalidates any persisted checkpoint.
next_usn: i64The next USN to read from; advances past each returned batch.
Implementations§
Source§impl UsnJournal
impl UsnJournal
Sourcepub fn open(drive: &str, start_usn: Option<i64>) -> Result<Self, UsnError>
pub fn open(drive: &str, start_usn: Option<i64>) -> Result<Self, UsnError>
Open the journal for tailing. Creates it when missing (requires
elevation, which the whole scan path already needs). start_usn is
the persisted checkpoint; pass None to start at the current end.
§Errors
Returns UsnError::OpenVolume if the volume handle cannot be opened,
or UsnError::Fsctl if creating or querying the journal fails.
Sourcepub const fn checkpoint_valid(
&self,
persisted_journal_id: u64,
data_first_usn: i64,
) -> bool
pub const fn checkpoint_valid( &self, persisted_journal_id: u64, data_first_usn: i64, ) -> bool
True if the persisted checkpoint is still replayable from this journal.
Sourcepub fn query(&self) -> Result<USN_JOURNAL_DATA_V0, UsnError>
pub fn query(&self) -> Result<USN_JOURNAL_DATA_V0, UsnError>
Query the live journal metadata (id and retained USN range).
§Errors
Returns UsnError::Fsctl if the FSCTL_QUERY_USN_JOURNAL call fails
(including a journal that is no longer active).
fn query_or_create( handle: &OwnedHandle, ) -> Result<USN_JOURNAL_DATA_V0, UsnError>
fn query_raw(handle: &OwnedHandle) -> Result<USN_JOURNAL_DATA_V0, QueryErr>
Sourcepub fn read_blocking(
&mut self,
buf: &mut Vec<u8>,
) -> Result<ReadOutcome, UsnError>
pub fn read_blocking( &mut self, buf: &mut Vec<u8>, ) -> Result<ReadOutcome, UsnError>
Blocking read: returns once at least one record is available (or the
journal became invalid). Advances next_usn past the returned batch.
§Errors
Returns UsnError::Fsctl if the FSCTL_READ_USN_JOURNAL call fails
for a reason other than a recoverable journal-gone condition (those
are reported through ReadOutcome).
Auto Trait Implementations§
impl Freeze for UsnJournal
impl RefUnwindSafe for UsnJournal
impl Send for UsnJournal
impl Sync for UsnJournal
impl Unpin for UsnJournal
impl UnsafeUnpin for UsnJournal
impl UnwindSafe for UsnJournal
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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