Skip to main content

OxiError

Enum OxiError 

Source
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

§offset: u64

Byte offset where the error occurred.

§message: String

Description of the parse error.

§

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.

Fields

§needed: usize

Required buffer size in bytes.

§have: usize

Available buffer size in bytes.

§

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

Source

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, .. }));
Source

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(_)));
Source

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(_)));
Source

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(_)));
Source

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 }));
Source

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());
Source

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());
Source

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(_)));
Source

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 Debug for OxiError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for OxiError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for OxiError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for OxiError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.