pub struct Parser<FS: FileSystem = NativeFs> { /* private fields */ }Expand description
The OneNote file parser.
Use Parser::parse_notebook to load a notebook from a .onetoc2 file or
Parser::parse_section to load a single .one section. These methods
auto-detect OneNote 2016 (desktop) and OneDrive (FSSHTTP) formats and will
return an error if the input is not the expected file type.
§Thread safety
The parser is stateless and can be shared across threads.
Implementations§
Source§impl<FS: FileSystem> Parser<FS>
impl<FS: FileSystem> Parser<FS>
Sourcepub fn new_with_fs(fs: FS) -> Parser<FS>
pub fn new_with_fs(fs: FS) -> Parser<FS>
Create a new instance of the Parser struct using the provided file system.
§Parameters
fs: An instance of an object implementing theFileSystemtrait. This parameter provides the necessary file system operations for theParser.
Sourcepub fn parse_notebook(&self, path: TypedPath<'_>) -> Result<Notebook>
pub fn parse_notebook(&self, path: TypedPath<'_>) -> Result<Notebook>
Parse a OneNote notebook.
The path argument must point to a .onetoc2 file. This will parse the
table of contents of the notebook as well as all contained
sections from the folder that the table of contents file is in. Each
returned Section carries its own Report of non-fatal warnings,
reachable via Section::report.
Returns ErrorKind::NotATocFile if the file is not a notebook table of
contents.
The notebook files are read on demand; mutating any of them while
a parse is in progress, or while a derived
crate::contents::Image / crate::contents::EmbeddedFile
is alive, is unsupported.
Sourcepub fn parse_section_buffer(
self,
data: &[u8],
file_name: TypedPath<'_>,
) -> Result<Section>
pub fn parse_section_buffer( self, data: &[u8], file_name: TypedPath<'_>, ) -> Result<Section>
Parse a OneNote section buffer.
The data argument must contain a OneNote section.
The file_name is used to populate section metadata and error messages.
Returns ErrorKind::NotASectionFile if the buffer does not contain a
section file.
Sourcepub fn dump_onestore(&self, data: &[u8]) -> Result<String>
pub fn dump_onestore(&self, data: &[u8]) -> Result<String>
Parse the raw OneStore layer from a buffer and return its Debug
representation.
Intended for tooling (e.g. the inspect binary) that needs to dump
the low-level OneStore structures of a .one or .onetoc2 file
without resolving them into the high-level Section / Notebook
types. The exact format of the returned string is unstable and should
not be parsed by scripts.
Sourcepub fn parse_section(&self, path: TypedPath<'_>) -> Result<Section>
pub fn parse_section(&self, path: TypedPath<'_>) -> Result<Section>
Parse a OneNote section file.
The path argument must point to a .one file that contains a
OneNote section. The returned Section carries any non-fatal warnings
encountered while parsing, reachable via Section::report.
Returns ErrorKind::NotASectionFile if the file does not contain a
section.
The file is read on demand; mutating it while a parse is in progress, or while a derived attachment is alive, is unsupported.
Sourcepub fn parse_package(&self, path: TypedPath<'_>) -> Result<Notebook>
pub fn parse_package(&self, path: TypedPath<'_>) -> Result<Notebook>
Parse a OneNote package (.onepkg) file.
.onepkg files are CAB archives bundling a .onetoc2 plus its .one
section files. This method decompresses the archive in memory and parses
the contained notebook without writing anything to disk.
Returns ErrorKind::MalformedPackage if the file is not a valid
cabinet or does not contain a .onetoc2 table of contents.
Trait Implementations§
Auto Trait Implementations§
impl<FS> Freeze for Parser<FS>where
FS: Freeze,
impl<FS> RefUnwindSafe for Parser<FS>where
FS: RefUnwindSafe,
impl<FS> Send for Parser<FS>
impl<FS> Sync for Parser<FS>
impl<FS> Unpin for Parser<FS>where
FS: Unpin,
impl<FS> UnsafeUnpin for Parser<FS>where
FS: UnsafeUnpin,
impl<FS> UnwindSafe for Parser<FS>where
FS: UnwindSafe,
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> 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