Skip to main content

SDL_IOStreamInterface

Struct SDL_IOStreamInterface 

Source
#[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

Source§

fn clone(&self) -> SDL_IOStreamInterface

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 SDL_IOStreamInterface

Source§

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

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

impl Default for SDL_IOStreamInterface

Source§

fn default() -> SDL_IOStreamInterface

Returns the “default value” for a type. Read more
Source§

impl Hash for SDL_IOStreamInterface

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Copy for SDL_IOStreamInterface

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, 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.