Struct sdl2::Sdl

source ·
pub struct Sdl { /* private fields */ }
Expand description

The SDL context type. Initialize with sdl2::init().

From a thread-safety perspective, Sdl represents the main thread. As such, Sdl is a useful type for ensuring that SDL types that can only be used on the main thread are initialized that way.

For instance, SDL_PumpEvents() is not thread safe, and may only be called on the main thread. All functionality that calls SDL_PumpEvents() is thus put into an EventPump type, which can only be obtained through Sdl. This guarantees that the only way to call event-pumping functions is on the main thread.

Implementations§

source§

impl Sdl

source

pub fn keyboard(&self) -> KeyboardUtil

source§

impl Sdl

source

pub fn mouse(&self) -> MouseUtil

source§

impl Sdl

source

pub fn audio(&self) -> Result<AudioSubsystem, String>

Initializes the audio subsystem.

source

pub fn event(&self) -> Result<EventSubsystem, String>

Initializes the event subsystem.

source

pub fn joystick(&self) -> Result<JoystickSubsystem, String>

Initializes the joystick subsystem.

source

pub fn haptic(&self) -> Result<HapticSubsystem, String>

Initializes the haptic subsystem.

source

pub fn game_controller(&self) -> Result<GameControllerSubsystem, String>

Initializes the game controller subsystem.

source

pub fn sensor(&self) -> Result<SensorSubsystem, String>

Initializes the game controller subsystem.

source

pub fn timer(&self) -> Result<TimerSubsystem, String>

Initializes the timer subsystem.

source

pub fn video(&self) -> Result<VideoSubsystem, String>

Initializes the video subsystem.

source

pub fn event_pump(&self) -> Result<EventPump, String>

Obtains the SDL event pump.

At most one EventPump is allowed to be alive during the program’s execution. If this function is called while an EventPump instance is alive, the function will return an error.

Trait Implementations§

source§

impl Clone for Sdl

source§

fn clone(&self) -> Sdl

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Sdl

§

impl !Send for Sdl

§

impl !Sync for Sdl

§

impl Unpin for Sdl

§

impl UnwindSafe for Sdl

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

§

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

§

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

§

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.