pub enum OxiError {
Io(Error),
Parse {
offset: u64,
message: String,
},
Codec(String),
Unsupported(String),
PatentViolation(String),
Eof,
BufferTooSmall {
needed: usize,
have: usize,
},
UnexpectedEof,
InvalidData(String),
UnknownFormat,
}Expand description
Error type for OxiMedia operations.
This enum covers all possible errors that can occur during multimedia processing, including I/O errors, parsing errors, codec errors, and patent violations.
§Examples
use oximedia_core::error::{OxiError, OxiResult};
fn parse_data(data: &[u8]) -> OxiResult<()> {
if data.is_empty() {
return Err(OxiError::Parse {
offset: 0,
message: "Empty data".to_string(),
});
}
Ok(())
}Variants§
Io(Error)
I/O error during file or stream operations.
Parse
Parse error at a specific offset in the data.
Fields
Codec(String)
Codec-related error.
Unsupported(String)
Unsupported format or feature.
PatentViolation(String)
Attempted to use a patent-encumbered codec.
OxiMedia only supports patent-free (Green List) codecs.
This error is returned when attempting to use codecs like
H.264, H.265, AAC, etc.
Eof
End of stream reached.
BufferTooSmall
Buffer is too small for the requested operation.
UnexpectedEof
Unexpected end of file during read operation.
This is returned when attempting to read beyond the end of available data.
InvalidData(String)
Invalid data encountered during parsing.
UnknownFormat
Format could not be recognized.
Implementations§
Source§impl OxiError
impl OxiError
Sourcepub fn parse(offset: u64, message: impl Into<String>) -> Self
pub fn parse(offset: u64, message: impl Into<String>) -> Self
Creates a new parse error at the given offset.
§Examples
use oximedia_core::error::OxiError;
let err = OxiError::parse(42, "Invalid header");
assert!(matches!(err, OxiError::Parse { offset: 42, .. }));Sourcepub fn codec(message: impl Into<String>) -> Self
pub fn codec(message: impl Into<String>) -> Self
Creates a new codec error.
§Examples
use oximedia_core::error::OxiError;
let err = OxiError::codec("Invalid frame data");
assert!(matches!(err, OxiError::Codec(_)));Sourcepub fn unsupported(message: impl Into<String>) -> Self
pub fn unsupported(message: impl Into<String>) -> Self
Creates a new unsupported format error.
§Examples
use oximedia_core::error::OxiError;
let err = OxiError::unsupported("H.265 is not supported");
assert!(matches!(err, OxiError::Unsupported(_)));Sourcepub fn patent_violation(codec_name: impl Into<String>) -> Self
pub fn patent_violation(codec_name: impl Into<String>) -> Self
Creates a new patent violation error.
§Examples
use oximedia_core::error::OxiError;
let err = OxiError::patent_violation("H.264");
assert!(matches!(err, OxiError::PatentViolation(_)));Sourcepub fn buffer_too_small(needed: usize, have: usize) -> Self
pub fn buffer_too_small(needed: usize, have: usize) -> Self
Creates a buffer too small error.
§Examples
use oximedia_core::error::OxiError;
let err = OxiError::buffer_too_small(1024, 512);
assert!(matches!(err, OxiError::BufferTooSmall { needed: 1024, have: 512 }));Sourcepub const fn is_eof(&self) -> bool
pub const fn is_eof(&self) -> bool
Returns true if this is an end-of-stream error.
§Examples
use oximedia_core::error::OxiError;
assert!(OxiError::Eof.is_eof());
assert!(!OxiError::codec("test").is_eof());Sourcepub const fn is_patent_violation(&self) -> bool
pub const fn is_patent_violation(&self) -> bool
Returns true if this is a patent violation error.
§Examples
use oximedia_core::error::OxiError;
assert!(OxiError::patent_violation("H.264").is_patent_violation());
assert!(!OxiError::Eof.is_patent_violation());Sourcepub fn invalid_data(message: impl Into<String>) -> Self
pub fn invalid_data(message: impl Into<String>) -> Self
Creates an invalid data error.
§Examples
use oximedia_core::error::OxiError;
let err = OxiError::invalid_data("Malformed header");
assert!(matches!(err, OxiError::InvalidData(_)));Sourcepub const fn is_unexpected_eof(&self) -> bool
pub const fn is_unexpected_eof(&self) -> bool
Returns true if this is an unexpected EOF error.
§Examples
use oximedia_core::error::OxiError;
assert!(OxiError::UnexpectedEof.is_unexpected_eof());
assert!(!OxiError::Eof.is_unexpected_eof());Trait Implementations§
Source§impl Error for OxiError
impl Error for OxiError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()