Skip to main content

OwnedWindow

Struct OwnedWindow 

Source
pub struct OwnedWindow(/* private fields */);
Expand description

The single owner of a Window: it deletes the window when dropped.

Nothing else deletes an owned window. The safe layer refuses to delete, clean away, own, reparent or reorder a window or an object containing one (see lvgl_rust_external_class_policy), raw code needs unsafe, and Window has no public delete. A window therefore lives exactly as long as its owner, which deletes it once.

LVGL can update a window while its owner waits for events. The owner exposes raw pointers for interoperation and uses a session for access. The waker is atomic and needs no session.

Taking ownership of a raw window requires unsafe:

ⓘ
fn adopt(window: core::ptr::NonNull<graphics::Window>) -> graphics::OwnedWindow {
    graphics::OwnedWindow::from_raw(window)
}

Safe code cannot borrow the window or read events without a session.

ⓘ
fn borrow(window: &graphics::OwnedWindow) {
    let _ = &**window;
}
ⓘ
fn read(window: &graphics::OwnedWindow) {
    window.peek_event();
}

Implementations§

Source§

impl OwnedWindow

Source

pub unsafe fn from_raw(window: NonNull<Window>) -> Self

Take ownership of a raw window.

§Safety

window must point to a live window (see Window::new) that nothing else owns or deletes. LVGL must stay initialized while the owner exists. Every window created inside it must be deleted first.

Source

pub fn into_raw(self) -> NonNull<Window>

Give up ownership without deleting the window. The caller becomes its owner: it deletes the window once, under the graphics lock, or hands it back to OwnedWindow::from_raw.

Source

pub fn delete(self, _lvgl: &mut Lvgl)

Delete the window in the current session.

Source

pub async fn close(self) -> Result<()>

Wait for the graphics lock and delete the window.

Source

pub fn as_object(&self) -> *mut lv_obj_t

The window’s LVGL object, for the raw bindings.

Source

pub fn as_object_mutable(&mut self) -> *mut lv_obj_t

The window’s LVGL object, for the raw bindings.

Source

pub fn get_identifier(&self) -> usize

Source

pub fn peek_event(&self, _lvgl: &Lvgl) -> Option<Event>

Source

pub fn pop_event(&mut self, _lvgl: &mut Lvgl) -> Option<Event>

Source

pub fn dropped_event_count(&self, _lvgl: &Lvgl) -> u32

Source

pub fn discard_events_for_target( &mut self, _lvgl: &mut Lvgl, target: *mut lv_obj_t, )

Source

pub fn get_icon<'a>(&'a self, _lvgl: &'a Lvgl) -> (&'a str, Color)

Source

pub fn set_icon( &mut self, _lvgl: &mut Lvgl, icon_string: &str, icon_color: Color, )

Set the icon using up to two Unicode scalar values. Text after a NUL is ignored.

Source

pub fn wake_up(&self)

Source

pub fn register_waker(&self, waker: &Waker)

Trait Implementations§

Source§

impl Drop for OwnedWindow

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl From<OwnedWindow> for NonNull<Window>

Source§

fn from(window: OwnedWindow) -> Self

Converts to this type from the input type.

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