heif_reader

Struct heif_reader 

Source
#[repr(C)]
pub struct heif_reader { pub reader_api_version: c_int, pub get_position: Option<unsafe extern "C" fn(userdata: *mut c_void) -> i64>, pub read: Option<unsafe extern "C" fn(data: *mut c_void, size: usize, userdata: *mut c_void) -> c_int>, pub seek: Option<unsafe extern "C" fn(position: i64, userdata: *mut c_void) -> c_int>, pub wait_for_file_size: Option<unsafe extern "C" fn(target_size: i64, userdata: *mut c_void) -> heif_reader_grow_status>, pub request_range: Option<unsafe extern "C" fn(start_pos: u64, end_pos: u64, userdata: *mut c_void) -> heif_reader_range_request_result>, pub preload_range_hint: Option<unsafe extern "C" fn(start_pos: u64, end_pos: u64, userdata: *mut c_void)>, pub release_file_range: Option<unsafe extern "C" fn(start_pos: u64, end_pos: u64, userdata: *mut c_void)>, pub release_error_msg: Option<unsafe extern "C" fn(msg: *const c_char)>, }

Fields§

§reader_api_version: c_int

API version supported by this reader

§get_position: Option<unsafe extern "C" fn(userdata: *mut c_void) -> i64>

— version 1 functions —

§read: Option<unsafe extern "C" fn(data: *mut c_void, size: usize, userdata: *mut c_void) -> c_int>

The functions read(), and seek() return 0 on success. Generally, libheif will make sure that we do not read past the file size.

§seek: Option<unsafe extern "C" fn(position: i64, userdata: *mut c_void) -> c_int>§wait_for_file_size: Option<unsafe extern "C" fn(target_size: i64, userdata: *mut c_void) -> heif_reader_grow_status>

When calling this function, libheif wants to make sure that it can read the file up to ‘target_size’. This is useful when the file is currently downloaded and may grow with time. You may, for example, extract the image sizes even before the actual compressed image data has been completely downloaded.

Even if your input files will not grow, you will have to implement at least detection whether the target_size is above the (fixed) file length (in this case, return ‘size_beyond_eof’).

§request_range: Option<unsafe extern "C" fn(start_pos: u64, end_pos: u64, userdata: *mut c_void) -> heif_reader_range_request_result>

If this function is defined, libheif will often request a file range before accessing it. The purpose of this function is that libheif will usually read very small chunks of data with the read() callback above. However, it is inefficient to request such a small chunk of data over a network and the network delay will significantly increase the decoding time. Thus, libheif will call request_range() with a larger block of data that should be preloaded and the subsequent read() calls will work within the requested ranges.

Note: end_pos is one byte after the last position to be read. You should return

  • ‘heif_reader_grow_status_size_reached’ if the requested range is available, or
  • ‘heif_reader_grow_status_size_beyond_eof’ if the requested range exceeds the file size (the valid part of the range has been read).
§preload_range_hint: Option<unsafe extern "C" fn(start_pos: u64, end_pos: u64, userdata: *mut c_void)>

libheif might issue hints when it assumes that a file range might be needed in the future. This may happen, for example, when your are doing selective tile accesses and libheif proposes to preload offset pointer tables. Another difference to request_file_range() is that this call should be non-blocking. If you preload any data, do this in a background thread.

§release_file_range: Option<unsafe extern "C" fn(start_pos: u64, end_pos: u64, userdata: *mut c_void)>

If libheif does not need access to a file range anymore, it may call this function to give a hint to the reader that it may release the range from a cache. If you do not maintain a file cache that wants to reduce its size dynamically, you do not need to implement this function.

§release_error_msg: Option<unsafe extern "C" fn(msg: *const c_char)>

Release an error message that was returned by heif_reader in an earlier call. If this function is NULL, the error message string will not be released. This is a viable option if you are only returning static strings.

Trait Implementations§

Source§

impl Clone for heif_reader

Source§

fn clone(&self) -> heif_reader

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for heif_reader

Source§

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

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

impl Copy for heif_reader

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.