pub enum HostId {
Alsa,
}Expand description
Unique identifier for available hosts on the platform.
Only the hosts supported by the current platform are available as enum variants.
For cross-platform code that needs to handle hosts from other platforms,
use the string representation via std::fmt::Display/std::str::FromStr.
§Available Host Strings
For cross-platform matching, these host strings are available:
"aaudio"- Android Audio"alsa"- Advanced Linux Sound Architecture"asio"- ASIO"coreaudio"- CoreAudio"custom"- Custom host (requirescustomfeature)"emscripten"- Emscripten"jack"- JACK Audio Connection Kit"null"- Null host"wasapi"- Windows Audio Session API"webaudio"- Web Audio API"audioworklet"- Audio Worklet
§Cross-Platform Example
use cpal::HostId;
use std::str::FromStr;
fn handle_host_string(host_string: &str) {
// String matching works on all platforms
match host_string {
"alsa" => println!("ALSA host"),
"coreaudio" => println!("CoreAudio host"),
"jack" => println!("JACK host"),
"wasapi" => println!("WASAPI host"),
"asio" => println!("ASIO host"),
"aaudio" => println!("AAudio host"),
_ => println!("Other host"),
}
// Parse host string (may fail if host is not available on this platform)
if let Ok(host_id) = HostId::from_str(host_string) {
println!("Successfully parsed: {}", host_id);
}
}Variants§
Alsa
Implementations§
Trait Implementations§
impl Copy for HostId
impl Eq for HostId
impl StructuralPartialEq for HostId
Auto Trait Implementations§
impl Freeze for HostId
impl RefUnwindSafe for HostId
impl Send for HostId
impl Sync for HostId
impl Unpin for HostId
impl UnsafeUnpin for HostId
impl UnwindSafe for HostId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more