#[repr(C)]pub struct SDL_IOStreamInterface {
pub version: Uint32,
pub size: Option<unsafe extern "C" fn(userdata: *mut c_void) -> Sint64>,
pub seek: Option<unsafe extern "C" fn(userdata: *mut c_void, offset: Sint64, whence: SDL_IOWhence) -> Sint64>,
pub read: Option<unsafe extern "C" fn(userdata: *mut c_void, ptr: *mut c_void, size: usize, status: *mut SDL_IOStatus) -> usize>,
pub write: Option<unsafe extern "C" fn(userdata: *mut c_void, ptr: *const c_void, size: usize, status: *mut SDL_IOStatus) -> usize>,
pub flush: Option<unsafe extern "C" fn(userdata: *mut c_void, status: *mut SDL_IOStatus) -> bool>,
pub close: Option<unsafe extern "C" fn(userdata: *mut c_void) -> bool>,
}Expand description
The function pointers that drive an SDL_IOStream.
Applications can provide this struct to SDL_OpenIO() to create their own implementation of SDL_IOStream. This is not necessarily required, as SDL already offers several common types of I/O streams, via functions like SDL_IOFromFile() and SDL_IOFromMem().
This structure should be initialized using SDL_INIT_INTERFACE()
Available Since: This struct is available since SDL 3.2.0.
See Also: SDL_INIT_INTERFACE
Fields§
§version: Uint32§size: Option<unsafe extern "C" fn(userdata: *mut c_void) -> Sint64>Return the number of bytes in this SDL_IOStream
Returns: the total size of the data stream, or -1 on error.
seek: Option<unsafe extern "C" fn(userdata: *mut c_void, offset: Sint64, whence: SDL_IOWhence) -> Sint64>Seek to offset relative to whence, one of stdio’s whence values:
SDL_IO_SEEK_SET, SDL_IO_SEEK_CUR, SDL_IO_SEEK_END
Returns: the final offset in the data stream, or -1 on error.
read: Option<unsafe extern "C" fn(userdata: *mut c_void, ptr: *mut c_void, size: usize, status: *mut SDL_IOStatus) -> usize>Read up to size bytes from the data stream to the area pointed
at by ptr. size will always be > 0.
On an incomplete read, you should set *status to a value from the
SDL_IOStatus enum. You do not have to explicitly set this on
a complete, successful read.
Returns: the number of bytes read
write: Option<unsafe extern "C" fn(userdata: *mut c_void, ptr: *const c_void, size: usize, status: *mut SDL_IOStatus) -> usize>Write exactly size bytes from the area pointed at by ptr
to data stream. size will always be > 0.
On an incomplete write, you should set *status to a value from the
SDL_IOStatus enum. You do not have to explicitly set this on
a complete, successful write.
Returns: the number of bytes written
flush: Option<unsafe extern "C" fn(userdata: *mut c_void, status: *mut SDL_IOStatus) -> bool>If the stream is buffering, make sure the data is written out.
On failure, you should set *status to a value from the
SDL_IOStatus enum. You do not have to explicitly set this on
a successful flush.
Returns: true if successful or false on write error when flushing data.
close: Option<unsafe extern "C" fn(userdata: *mut c_void) -> bool>Close and free any allocated resources.
This does not guarantee file writes will sync to physical media; they can be in the system’s file cache, waiting to go to disk.
The SDL_IOStream is still destroyed even if this fails, so clean up anything even if flushing buffers, etc, returns an error.
Returns: true if successful or false on write error when flushing data.
Trait Implementations§
Source§impl Clone for SDL_IOStreamInterface
impl Clone for SDL_IOStreamInterface
Source§fn clone(&self) -> SDL_IOStreamInterface
fn clone(&self) -> SDL_IOStreamInterface
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more