Add utils for ptr->&str conversion
This commit is contained in:
@ -48,19 +48,17 @@ pub mod decoder;
|
||||
pub mod encoder;
|
||||
pub mod traits;
|
||||
|
||||
use std::ffi::CStr;
|
||||
use std::str::from_utf8_unchecked;
|
||||
|
||||
use crate::ffi::*;
|
||||
use crate::utils;
|
||||
|
||||
pub fn version() -> u32 {
|
||||
unsafe { avcodec_version() }
|
||||
}
|
||||
|
||||
pub fn configuration() -> &'static str {
|
||||
unsafe { from_utf8_unchecked(CStr::from_ptr(avcodec_configuration()).to_bytes()) }
|
||||
unsafe { utils::str_from_c_ptr(avcodec_configuration()) }
|
||||
}
|
||||
|
||||
pub fn license() -> &'static str {
|
||||
unsafe { from_utf8_unchecked(CStr::from_ptr(avcodec_license()).to_bytes()) }
|
||||
unsafe { utils::str_from_c_ptr(avcodec_license()) }
|
||||
}
|
||||
|
Reference in New Issue
Block a user