#[cfg(target_os = "macos")]
mod iosurface_ext;
mod error;
mod server;
mod client;
mod directory;
mod utils;
mod metal_device;
pub use error::{SyphonError, Result};
pub use server::{SyphonServer, ServerOptions};
pub use client::{SyphonClient, Frame};
pub use directory::{SyphonServerDirectory, ServerInfo};
pub use utils::{to_nsstring, from_nsstring, class_exists};
pub use metal_device::{
MetalDeviceInfo,
default_device,
available_devices,
recommended_high_performance_device,
check_device_compatibility,
validate_device_match,
get_device_info,
};
pub fn is_available() -> bool {
#[cfg(target_os = "macos")]
{
class_exists("SyphonServer")
}
#[cfg(not(target_os = "macos"))]
{
false
}
}
pub fn version() -> Option<String> {
#[cfg(target_os = "macos")]
{
use objc::runtime::Class;
use objc::{msg_send, sel, sel_impl};
unsafe {
let cls = Class::get("SyphonServer")?;
let version: *mut objc::runtime::Object = msg_send![cls, version];
Some(utils::from_nsstring(version))
}
}
#[cfg(not(target_os = "macos"))]
{
None
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_availability() {
let available = is_available();
#[cfg(target_os = "macos")]
println!("Syphon available: {}", available);
#[cfg(not(target_os = "macos"))]
assert!(!available);
}
#[test]
fn test_version() {
if let Some(v) = version() {
println!("Syphon version: {}", v);
}
}
}