pub struct Parser { /* private fields */ }Expand description
Reusable parser with an explicit input policy.
Implementations§
Source§impl Parser
impl Parser
Sourcepub const fn new(options: ParseOptions) -> Self
pub const fn new(options: ParseOptions) -> Self
Create a parser with the supplied include and compression policies.
Sourcepub const fn options(&self) -> &ParseOptions
pub const fn options(&self) -> &ParseOptions
Return this parser’s immutable configuration.
Sourcepub fn parse_file(
&self,
path: impl AsRef<Path>,
) -> Result<ParseReport, ParseError>
pub fn parse_file( &self, path: impl AsRef<Path>, ) -> Result<ParseReport, ParseError>
Parse one source path into an owned document.
Auto-detected file input supports libmandoc’s native gzip handling and
zstd files. .so expansion is governed by IncludePolicy.
§Errors
Returns ParseError when the path cannot be represented for C, the
source cannot be read or decoded, or libmandoc rejects the source.
Sourcepub fn parse_bytes(
&self,
source_path: impl AsRef<Path>,
source: &[u8],
) -> Result<ParseReport, ParseError>
pub fn parse_bytes( &self, source_path: impl AsRef<Path>, source: &[u8], ) -> Result<ParseReport, ParseError>
Parse caller-owned source bytes under a logical source path.
Byte input is useful when a caller owns its transport or decompression
layer. In auto mode zstd magic is recognized; gzip byte input should
use Parser::parse_file so libmandoc can open it natively.
§Errors
Returns ParseError when the logical path is invalid, the requested
zstd decoding fails, or libmandoc rejects the supplied roff bytes.