Trait wlc::Handle [] [src]

pub trait Handle {
    fn set_user_data<T: Any>(&self, data: T);
    unsafe fn user_data<T: Any>(&self) -> Option<Rc<T>>;
    unsafe fn try_take_user_data<T: Any>(&self) -> Option<T>;
    fn clear_user_data(&self);
}

Assiciated user-provided data

Types implemeting Handle (Output, View) may hold a pointer to user-data. This Trait handles storing and receiving arbitrary data for such Types.

Required Methods

Sets any data as user pointer consuming the data.

Clears old user data before inserting new one (drops it correctly).

Receive a shared reference to the user data of a given type, if user data exists.

Returns None if no user data is set.

Safety

While the function confirms that userdata does actually exists, it does not verify that T is the correct Type for the data making it unsafe if the wrong type is used.

Tries to take the userdata exclusively and removes it from the Handle.

Returns None if no data exists or shared references do exist that make taking impossible.

Safety

While the function confirms that userdata does actually exists, it does not verify that T is the correct Type for the data making it unsafe if the wrong type is used.

Clears currently set user data (Drop gets called, after all references are dropped).

This is safe and a no-op if no user data exists

Implementors