Struct lofty::ParseOptions
source · #[non_exhaustive]pub struct ParseOptions { /* private fields */ }Expand description
Options to control how Lofty parses a file
Implementations§
source§impl ParseOptions
impl ParseOptions
sourcepub const DEFAULT_PARSING_MODE: ParsingMode = ParsingMode::BestAttempt
pub const DEFAULT_PARSING_MODE: ParsingMode = ParsingMode::BestAttempt
Default parsing mode
sourcepub const DEFAULT_MAX_JUNK_BYTES: usize = 1_024usize
pub const DEFAULT_MAX_JUNK_BYTES: usize = 1_024usize
Default number of junk bytes to read
sourcepub const DEFAULT_ALLOCATION_LIMIT: usize = 16_777_216usize
pub const DEFAULT_ALLOCATION_LIMIT: usize = 16_777_216usize
Default allocation limit for any single tag item
sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates a new ParseOptions, alias for Default implementation
See also: ParseOptions::default
Examples
use lofty::ParseOptions;
let parsing_options = ParseOptions::new();sourcepub fn read_properties(&mut self, read_properties: bool) -> Self
pub fn read_properties(&mut self, read_properties: bool) -> Self
Whether or not to read the audio properties
Examples
use lofty::ParseOptions;
// By default, `read_properties` is enabled. Here, we don't want to read them.
let parsing_options = ParseOptions::new().read_properties(false);sourcepub fn use_custom_resolvers(&mut self, use_custom_resolvers: bool) -> Self
pub fn use_custom_resolvers(&mut self, use_custom_resolvers: bool) -> Self
Whether or not to check registered custom resolvers
See also: crate::resolve
Examples
use lofty::ParseOptions;
// By default, `use_custom_resolvers` is enabled. Here, we don't want to use them.
let parsing_options = ParseOptions::new().use_custom_resolvers(false);sourcepub fn parsing_mode(&mut self, parsing_mode: ParsingMode) -> Self
pub fn parsing_mode(&mut self, parsing_mode: ParsingMode) -> Self
The parsing mode to use, see ParsingMode for details
Examples
use lofty::{ParseOptions, ParsingMode};
// By default, `parsing_mode` is ParsingMode::BestAttempt. Here, we need absolute correctness.
let parsing_options = ParseOptions::new().parsing_mode(ParsingMode::Strict);sourcepub fn max_junk_bytes(&mut self, max_junk_bytes: usize) -> Self
pub fn max_junk_bytes(&mut self, max_junk_bytes: usize) -> Self
The maximum number of allowed junk bytes to search
Some information may be surrounded by junk bytes, such as tag padding remnants. This sets the maximum number of junk/unrecognized bytes Lofty will search for required information before giving up.
Examples
use lofty::ParseOptions;
// I have files full of junk, I'll double the search window!
let parsing_options = ParseOptions::new().max_junk_bytes(2048);sourcepub fn allocation_limit(&mut self, allocation_limit: usize) -> Self
pub fn allocation_limit(&mut self, allocation_limit: usize) -> Self
The maximum number of bytes to allocate for any single tag item
This is a safety measure to prevent allocating too much memory for a single tag item. If a tag item
exceeds this limit, the allocator will return crate::error::ErrorKind::TooMuchData.
NOTE: This only needs to be set once per thread. The limit will be used for all subsequent reads, until a new one is set.
Examples
use lofty::ParseOptions;
// I have files with gigantic images, I'll double the allocation limit!
let parsing_options = ParseOptions::new().allocation_limit(32 * 1024 * 1024);Trait Implementations§
source§impl Clone for ParseOptions
impl Clone for ParseOptions
source§fn clone(&self) -> ParseOptions
fn clone(&self) -> ParseOptions
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for ParseOptions
impl Debug for ParseOptions
source§impl Default for ParseOptions
impl Default for ParseOptions
source§impl Ord for ParseOptions
impl Ord for ParseOptions
source§fn cmp(&self, other: &ParseOptions) -> Ordering
fn cmp(&self, other: &ParseOptions) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for ParseOptions
impl PartialEq for ParseOptions
source§fn eq(&self, other: &ParseOptions) -> bool
fn eq(&self, other: &ParseOptions) -> bool
self and other values to be equal, and is used
by ==.source§impl PartialOrd for ParseOptions
impl PartialOrd for ParseOptions
source§fn partial_cmp(&self, other: &ParseOptions) -> Option<Ordering>
fn partial_cmp(&self, other: &ParseOptions) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more