System

Struct System 

Source
pub struct System<Api = Default>(/* private fields */);

Implementations§

Source§

impl<Api: Api> System<Api>

Source

pub fn set_update_callback<'u, U, F>( &self, on_update: F, userdata: U, ) -> Handler<'u, F, U>
where U: 'u, F: 'u + FnMut(&mut U) -> UpdateCtrl,

Takes any function and userdata, registers callback in the system and returns this function with userdata wrapped into the Handler with [Pin] inside.

For register a fn-ptr you could better use [set_update_callback_static].

Safety is ensured by Handler, that resets the system registered update handler when drop.

Wrapping sys::ffi::playdate_sys::setUpdateCallback

Source

pub fn set_update_callback_boxed<'u, U, F>(&self, on_update: F, userdata: U)
where U: 'u, F: 'u + FnMut(&mut U) -> UpdateCtrl,

Consumes and leaks an any function with userdata into the Box, registers callback in the system.

For register a fn-ptr you could better use [set_update_callback_static].

Safety is guaranteed by the caller.

See also System::set_update_callback, it prevents leaks and more safe.

Wrapping sys::ffi::playdate_sys::setUpdateCallback

Source

pub fn set_update_callback_static<U: 'static>( &self, on_update: Option<fn(userdata: &mut U) -> UpdateCtrl>, userdata: U, )

Consumes and leaks function on_update and userdata, wraps it into the Box, then registers callback.

See also System::set_update_callback, it prevents leaks and more safe.

Wrapping sys::ffi::playdate_sys::setUpdateCallback

Source

pub fn set_update_handler<'t, U: 'static + Update>( &'t self, handler: Option<&'static mut U>, )
where &'t Api: Api,

Executes handler’s Update::set_update_handler_with with this inner api.

Wrapping sys::ffi::playdate_sys::setUpdateCallback

Source§

impl System<Default>

Source

pub fn Default() -> Self

Creates default System without type parameter requirement.

Uses ZST api::Default.

Source§

impl System<Cache>

Source

pub fn Cached() -> Self

Creates System without type parameter requirement.

Uses api::Cache.

Source§

impl<Api: Default + Api> System<Api>

Source

pub fn new() -> Self

Source§

impl<Api: Api> System<Api>

Source

pub fn new_with(api: Api) -> Self

Source

pub const fn inner(&self) -> Api
where Api: Copy,

Source§

impl<Api: Api> System<Api>

Source

pub fn language(&self) -> PDLanguage

Source

pub fn current_time(&self) -> Duration

Source

pub fn current_time_ms(&self) -> c_uint

Source

pub fn seconds_since_epoch(&self) -> c_uint

Returns the number of seconds elapsed since midnight (hour 0), January 1, 2000.

See also System::seconds_since_epoch_with_ms.

Equivalent to sys::ffi::playdate_sys::getSecondsSinceEpoch

Source

pub fn seconds_since_epoch_with_ms(&self) -> (c_uint, c_uint)

Returns current time as (seconds, milliseconds), elapsed since midnight (hour 0), January 1, 2000.

Equivalent to sys::ffi::playdate_sys::getSecondsSinceEpoch

Source

pub fn time_since_epoch(&self) -> Duration

Source

pub fn draw_fps(&self, x: c_int, y: c_int)

Source

pub fn flipped(&self) -> bool

Source

pub fn set_auto_lock_disabled(&self, disable: bool)

Source

pub fn reduce_flashing(&self) -> bool

Source

pub fn elapsed_time_secs(&self) -> c_float

Returns the number of seconds since [reset_elapsed_time] was called.

The value is a floating-point number with microsecond accuracy.

Equivalent to sys::ffi::playdate_sys::getElapsedTime

Source

pub fn elapsed_time(&self) -> Duration

Source

pub fn reset_elapsed_time(&self)

Source

pub fn battery_percentage(&self) -> c_float

Source

pub fn battery_voltage(&self) -> c_float

Source

pub fn timezone_offset(&self) -> i32

Source

pub fn should_display_24_hour_time(&self) -> bool

Source

pub fn convert_epoch_to_date_time(&self, epoch: u32) -> PDDateTime

Source

pub fn convert_epoch_to_date_time_to(&self, epoch: u32, dt: &mut PDDateTime)

Source

pub fn convert_date_time_to_epoch(&self, dt: &PDDateTime) -> u32

Source

pub fn set_serial_message_callback<F>(&self, callback: Option<F>)
where F: 'static + FnMut(String) + Sized,

Trait Implementations§

Source§

impl<Api: Clone> Clone for System<Api>

Source§

fn clone(&self) -> System<Api>

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl<Api: Debug> Debug for System<Api>

Source§

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

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

impl<Api: Default + Api> Default for System<Api>

Source§

fn default() -> Self

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

impl<Api: Copy> Copy for System<Api>

Auto Trait Implementations§

§

impl<Api> Freeze for System<Api>
where Api: Freeze,

§

impl<Api> RefUnwindSafe for System<Api>
where Api: RefUnwindSafe,

§

impl<Api> Send for System<Api>
where Api: Send,

§

impl<Api> Sync for System<Api>
where Api: Sync,

§

impl<Api> Unpin for System<Api>
where Api: Unpin,

§

impl<Api> UnwindSafe for System<Api>
where Api: UnwindSafe,

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

Layout§

Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.