pub struct HostSharedHandle<'a> { /* private fields */ }Expand description
A thread-safe handle to the host.
This can be used to fetch information about the host, scan available extensions, or perform requests to the host.
Implementations§
Sourcepub const fn as_raw(&self) -> &'a clap_host
pub const fn as_raw(&self) -> &'a clap_host
Returns a raw, C FFI-compatible reference to the host handle.
Sourcepub const fn as_info(&self) -> &HostInfo<'a>
pub const fn as_info(&self) -> &HostInfo<'a>
Returns this handle as a reference to the host’s information.
Sourcepub fn request_restart(&self)
pub fn request_restart(&self)
Requests the host to deactivate and then re-activate the plugin. The operation may be delayed by the host.
Sourcepub fn request_process(&self)
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”.
Sourcepub fn request_callback(&self)
pub fn request_callback(&self)
Requests the host to schedule a call to the on_main_thread method on the main thread.
Sourcepub const unsafe fn as_main_thread_unchecked(&self) -> HostMainThreadHandle<'a>
pub const 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.
Sourcepub const unsafe fn as_audio_processor_unchecked(
&self,
) -> HostAudioProcessorHandle<'a>
pub const 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.
Sourcepub fn use_extension<E: Sized>(
&self,
extension: &RawExtension<HostExtensionSide, E>,
) -> &'a E
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.
Sourcepub unsafe fn from_raw(raw: NonNull<clap_host>) -> Self
pub unsafe fn from_raw(raw: NonNull<clap_host>) -> Self
Creates a HostSharedHandle from a raw clap_host pointer.
§Safety
Sourcepub unsafe fn with_arbitrary_lifetime<'b>(&self) -> HostSharedHandle<'b>
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>>§
Sourcepub fn clap_version(&self) -> ClapVersion
pub fn clap_version(&self) -> ClapVersion
The ClapVersion the host uses.
Sourcepub fn name(&self) -> Option<&'a CStr>
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.
Sourcepub fn vendor(&self) -> Option<&'a CStr>
pub fn vendor(&self) -> Option<&'a CStr>
The host’s vendor (e.g. “Bitwig GmbH”).
This field is optional.
Sourcepub fn version(&self) -> Option<&'a CStr>
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.
Sourcepub fn get_extension<E: Extension<ExtensionSide = HostExtensionSide>>(
&self,
) -> Option<E>
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
}Trait Implementations§
Source§fn clone(&self) -> HostSharedHandle<'a>
fn clone(&self) -> HostSharedHandle<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more