util/error: implement From for Error
This commit is contained in:
parent
7f6d694a7d
commit
8bdb50ebaf
@ -1,11 +1,12 @@
|
|||||||
use ffi::*;
|
|
||||||
use std::error;
|
use std::error;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use libc::c_int;
|
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use std::str::from_utf8_unchecked;
|
use std::str::from_utf8_unchecked;
|
||||||
|
|
||||||
|
use libc::c_int;
|
||||||
|
use ffi::*;
|
||||||
|
|
||||||
pub struct Error {
|
pub struct Error {
|
||||||
code: c_int,
|
code: c_int,
|
||||||
desc: RefCell<Option<[i8; AV_ERROR_MAX_STRING_SIZE as usize]>>,
|
desc: RefCell<Option<[i8; AV_ERROR_MAX_STRING_SIZE as usize]>>,
|
||||||
@ -17,6 +18,12 @@ impl Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<c_int> for Error {
|
||||||
|
fn from(value: c_int) -> Error {
|
||||||
|
Error::new(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl fmt::Display for Error {
|
impl fmt::Display for Error {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||||
f.write_str(error::Error::description(self))
|
f.write_str(error::Error::description(self))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user