#[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_intAPI 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
impl Clone for heif_reader
Source§fn clone(&self) -> heif_reader
fn clone(&self) -> heif_reader
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more