EventHandle

Struct EventHandle 

Source
pub struct EventHandle<T: ?Sized> { /* private fields */ }
Expand description

Handle returned when registering callbacks.

Automatically unregisters the callback when dropped, implementing RAII cleanup pattern to prevent memory leaks.

§Examples

use telegram_webapp_sdk::TelegramWebApp;

if let Some(app) = TelegramWebApp::instance() {
    // Handle is automatically cleaned up when scope ends
    let handle = app
        .on_theme_changed(|| {
            println!("Theme changed!");
        })
        .expect("subscribe");

    // No manual cleanup needed - Drop handles it
} // <- handle dropped here, callback unregistered automatically

Trait Implementations§

Source§

impl<T: ?Sized> Drop for EventHandle<T>

Source§

fn drop(&mut self)

Automatically unregisters the event callback when the handle is dropped.

This implements the RAII pattern, ensuring that event handlers are properly cleaned up even if the user forgets to manually unregister. Errors during unregistration are logged but do not panic.

Auto Trait Implementations§

§

impl<T> Freeze for EventHandle<T>
where T: ?Sized,

§

impl<T> RefUnwindSafe for EventHandle<T>
where T: RefUnwindSafe + ?Sized,

§

impl<T> !Send for EventHandle<T>

§

impl<T> !Sync for EventHandle<T>

§

impl<T> Unpin for EventHandle<T>
where T: ?Sized,

§

impl<T> UnwindSafe for EventHandle<T>
where T: UnwindSafe + ?Sized,

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.