Struct SDL_IOStreamInterface
#[repr(C)]pub struct SDL_IOStreamInterface {
pub version: u32,
pub size: Option<unsafe extern "C" fn(_: *mut c_void) -> i64>,
pub seek: Option<unsafe extern "C" fn(_: *mut c_void, _: i64, _: SDL_IOWhence) -> i64>,
pub read: Option<unsafe extern "C" fn(_: *mut c_void, _: *mut c_void, _: usize, _: *mut SDL_IOStatus) -> usize>,
pub write: Option<unsafe extern "C" fn(_: *mut c_void, _: *const c_void, _: usize, _: *mut SDL_IOStatus) -> usize>,
pub flush: Option<unsafe extern "C" fn(_: *mut c_void, _: *mut SDL_IOStatus) -> bool>,
pub close: Option<unsafe extern "C" fn(_: *mut c_void) -> bool>,
}
dep_sdl3
only.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()
§Availability
This struct is available since SDL 3.2.0.
§See also
Fields§
§version: u32
§size: Option<unsafe extern "C" fn(_: *mut c_void) -> i64>
Return the number of bytes in this SDL_IOStream
\return the total size of the data stream, or -1 on error.
seek: Option<unsafe extern "C" fn(_: *mut c_void, _: i64, _: SDL_IOWhence) -> i64>
Seek to offset
relative to whence
, one of stdio’s whence values:
SDL_IO_SEEK_SET
, SDL_IO_SEEK_CUR
, SDL_IO_SEEK_END
\return the final offset in the data stream, or -1 on error.
read: Option<unsafe extern "C" fn(_: *mut c_void, _: *mut c_void, _: usize, _: *mut SDL_IOStatus) -> usize>
Read up to size
bytes from the data stream to the area pointed
at by ptr
.
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.
\return the number of bytes read
write: Option<unsafe extern "C" fn(_: *mut c_void, _: *const c_void, _: usize, _: *mut SDL_IOStatus) -> usize>
Write exactly size
bytes from the area pointed at by ptr
to data stream.
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.
\return the number of bytes written
flush: Option<unsafe extern "C" fn(_: *mut c_void, _: *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.
\return true if successful or false on write error when flushing data.
close: Option<unsafe extern "C" fn(_: *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.
\return true if successful or false on write error when flushing data.
Implementations§
§impl SDL_IOStreamInterface
impl SDL_IOStreamInterface
pub const fn new() -> SDL_IOStreamInterface
pub const fn new() -> SDL_IOStreamInterface
Create a new SDL_IOStreamInterface
initialized with SDL_INIT_INTERFACE
Trait Implementations§
§impl Default for SDL_IOStreamInterface
impl Default for SDL_IOStreamInterface
§fn default() -> SDL_IOStreamInterface
fn default() -> SDL_IOStreamInterface
Create a new SDL_IOStreamInterface
initialized with SDL_INIT_INTERFACE
Auto Trait Implementations§
impl Freeze for SDL_IOStreamInterface
impl RefUnwindSafe for SDL_IOStreamInterface
impl Send for SDL_IOStreamInterface
impl Sync for SDL_IOStreamInterface
impl Unpin for SDL_IOStreamInterface
impl UnwindSafe for SDL_IOStreamInterface
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ByteSized for T
impl<T> ByteSized for T
Source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Source§fn byte_align(&self) -> usize
fn byte_align(&self) -> usize
Source§fn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Source§impl<T, R> Chain<R> for Twhere
T: ?Sized,
impl<T, R> Chain<R> for Twhere
T: ?Sized,
Source§impl<T> ExtAny for T
impl<T> ExtAny for T
Source§fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
TypeId
of Self
using a custom hasher.Source§fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Source§impl<T> ExtMem for Twhere
T: ?Sized,
impl<T> ExtMem for Twhere
T: ?Sized,
Source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Source§fn mem_align_of<T>() -> usize
fn mem_align_of<T>() -> usize
Source§fn mem_align_of_val(&self) -> usize
fn mem_align_of_val(&self) -> usize
Source§fn mem_size_of<T>() -> usize
fn mem_size_of<T>() -> usize
Source§fn mem_size_of_val(&self) -> usize
fn mem_size_of_val(&self) -> usize
Source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true
if dropping values of this type matters. Read moreSource§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self
without running its destructor. Read moreSource§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Source§unsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
unsafe_slice
only.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Hook for T
impl<T> Hook for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more