pub struct FormatDetector { /* private fields */ }Expand description
Centralized format detector for SBOM content.
Provides consistent detection logic for both standard and streaming parsers.
Implementations§
Source§impl FormatDetector
impl FormatDetector
Sourcepub const fn with_threshold(min_confidence: f32) -> Self
pub const fn with_threshold(min_confidence: f32) -> Self
Create a format detector with a custom confidence threshold.
Sourcepub fn detect_from_content(&self, content: &str) -> DetectionResult
pub fn detect_from_content(&self, content: &str) -> DetectionResult
Detect format from full content string.
This performs full detection using each parser’s detect() method.
Sourcepub fn detect_from_peek(&self, peek: &[u8]) -> DetectionResult
pub fn detect_from_peek(&self, peek: &[u8]) -> DetectionResult
Detect format from peeked bytes (for streaming).
This performs detection using a prefix of the content, suitable for streaming parsers that can only peek at the beginning of a file.
Sourcepub fn parse_str(&self, content: &str) -> Result<NormalizedSbom, ParseError>
pub fn parse_str(&self, content: &str) -> Result<NormalizedSbom, ParseError>
Parse content using the detected format.
This combines detection and parsing in a single operation.
Sourcepub fn parse_reader<R: BufRead>(
&self,
reader: R,
) -> Result<NormalizedSbom, ParseError>
pub fn parse_reader<R: BufRead>( &self, reader: R, ) -> Result<NormalizedSbom, ParseError>
Parse from a reader using streaming JSON parsing.
Peeks at the content to detect format, then uses the appropriate reader-based parser for memory-efficient parsing.
Sourcepub const fn cyclonedx_parser(&self) -> &CycloneDxParser
pub const fn cyclonedx_parser(&self) -> &CycloneDxParser
Get a reference to the CycloneDX parser.
Sourcepub const fn spdx_parser(&self) -> &SpdxParser
pub const fn spdx_parser(&self) -> &SpdxParser
Get a reference to the SPDX parser.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FormatDetector
impl RefUnwindSafe for FormatDetector
impl Send for FormatDetector
impl Sync for FormatDetector
impl Unpin for FormatDetector
impl UnsafeUnpin for FormatDetector
impl UnwindSafe for FormatDetector
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> 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