Skip to main content

HostMainThreadHandle

Struct HostMainThreadHandle 

Source
pub struct HostMainThreadHandle<'a> { /* private fields */ }
Expand description

A main-thread handle to the host.

This can be used to perform requests to the host that can only be made from the main thread.

Implementations§

Source§

impl<'a> HostMainThreadHandle<'a>

Source

pub const fn shared(&self) -> HostSharedHandle<'a>

Gets a thread-safe host handle from this handle.

Source

pub const fn as_shared(&self) -> &HostSharedHandle<'a>

Returns this handle as a reference to a thread-safe host handle from this handle.

Source

pub const fn as_raw(&self) -> &'a clap_host

Returns a raw, C FFI-compatible reference to the host handle.

Source

pub unsafe fn from_raw(raw: NonNull<clap_host>) -> Self

Creates a HostMainThreadHandle from a raw clap_host pointer.

§Safety
Source

pub unsafe fn with_arbitrary_lifetime<'b>(&self) -> HostMainThreadHandle<'b>

Returns a HostMainThreadHandle that points to the same host, but with an arbitrary lifetime instead of the host’s.

This can be useful in situations where you need to use host callbacks in a container that does not let you use proper lifetimes, but you can still guarantee that host callbacks won’t be called after the host’s 'a lifetime.

§Safety

The returned handle’s lifetime is completely meaningless here. Proper care muse be taken in order to ensure no methods on this type are used beyond the original host 'a lifetime.

Methods from Deref<Target = HostSharedHandle<'a>>§

Source

pub fn info(&self) -> HostInfo<'a>

Returns the host’s information.

Source

pub fn as_raw(&self) -> &'a clap_host

Returns a raw, C FFI-compatible reference to the host handle.

Source

pub fn as_info(&self) -> &HostInfo<'a>

Returns this handle as a reference to the host’s information.

Source

pub fn request_restart(&self)

Requests the host to deactivate and then re-activate the plugin. The operation may be delayed by the host.

Source

pub fn request_process(&self)

Requests the host to activate the plugin, and start audio processing. This is useful if you have external IO and need to wake the plugin up from “sleep”.

Source

pub fn request_callback(&self)

Requests the host to schedule a call to the on_main_thread method on the main thread.

Source

pub unsafe fn as_main_thread_unchecked(&self) -> HostMainThreadHandle<'a>

Unsafely creates a main-thread host handle from this thread-safe handle.

§Safety

Callers MUST ensure this is only called on the main thread, and that they have exclusive (&mut) access.

Source

pub unsafe fn as_audio_processor_unchecked( &self, ) -> HostAudioProcessorHandle<'a>

Unsafely creates an audio-processor host handle from this thread-safe handle.

§Safety

Callers MUST ensure this is only called on the audio thread, and that they have exclusive (&mut) access.

Source

pub fn use_extension<E: Sized>( &self, extension: &RawExtension<HostExtensionSide, E>, ) -> &'a E

Safely dereferences a RawExtension pointer produced by this host.

See the documentation of the RawExtension type for more information about how this works internally.

§Panics

This method will panic if the given extension pointer does not match the host this handle came from.

Source

pub unsafe fn with_arbitrary_lifetime<'b>(&self) -> HostSharedHandle<'b>

Returns a HostSharedHandle that points to the same host, but with an arbitrary lifetime instead of the host’s.

This can be useful in situations where you need to use host callbacks in a container that does not let you use proper lifetimes, but you can still guarantee that host callbacks won’t be called after the host’s 'a lifetime.

§Safety

The returned handle’s lifetime is completely meaningless here. Proper care muse be taken in order to ensure no methods on this type are used beyond the original host 'a lifetime.

Methods from Deref<Target = HostInfo<'a>>§

Source

pub fn clap_version(&self) -> ClapVersion

The ClapVersion the host uses.

Source

pub fn name(&self) -> Option<&'a CStr>

A user-friendly name for the host (e.g. “Bitwig Studio”).

This should always be set by the host.

Source

pub fn vendor(&self) -> Option<&'a CStr>

The host’s vendor (e.g. “Bitwig GmbH”).

This field is optional.

Source

pub fn url(&self) -> Option<&'a CStr>

A URL to the host’s webpage.

This field is optional.

Source

pub fn version(&self) -> Option<&'a CStr>

A version string for the host (e.g. “4.3”).

This should always be set by the host.

Source

pub fn get_extension<E: Extension<ExtensionSide = HostExtensionSide>>( &self, ) -> Option<E>

Retrieves the host’s pointer to the given extension type E.

This returns None if the host does not support the given extension.

§Example
use clack_extensions::log::{HostLog, LogSeverity};
use clack_plugin::host::HostInfo;

let info: HostInfo = /* ... */
if let Some(log) = info.get_extension::<HostLog>() {
    // The log extension is supported by this host
} else {
    // The log extension is not supported by this host
}
Source

pub fn as_raw(&self) -> &'a clap_host

Returns a raw, C FFI-compatible reference to the host handle.

Trait Implementations§

Source§

impl<'a> Clone for HostMainThreadHandle<'a>

Source§

fn clone(&self) -> HostMainThreadHandle<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for HostMainThreadHandle<'a>

Source§

impl<'a> Deref for HostMainThreadHandle<'a>

Source§

type Target = HostSharedHandle<'a>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'a> From<HostMainThreadHandle<'a>> for HostSharedHandle<'a>

Source§

fn from(h: HostMainThreadHandle<'a>) -> 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> CloneToUninit for T
where T: Clone,

Source§

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
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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.