### Run Example on iOS Device Source: https://github.com/yury/cidre/blob/main/README.md Run a specific example, such as 'device-formats', on your connected iOS device using the cargo run command with the appropriate target. ```bash cargo r --target aarch64-apple-ios --example device-formats ``` -------------------------------- ### Metal GPU Rendering Setup Source: https://github.com/yury/cidre/blob/main/_autodocs/README.md Shows the basic setup for Metal GPU rendering, including device, command queue, and command buffer creation. ```rust use cidre::mtl; // Get GPU device let device = mtl::Device::default(); // Create command queue let queue = device.new_command_queue().unwrap(); // Record commands let cmd_buf = queue.new_command_buffer().unwrap(); let render_enc = cmd_buf.new_render_command_encoder_with_desc(&pass_desc)?; // Render render_enc.set_render_pipeline_state(&state); render_enc.draw_primitives(mtl::PrimitiveType::Triangle, 0, 3); render_enc.end_encoding(); // Submit cmd_buf.present_drawable(&drawable); cmd_buf.commit(); cmd_buf.wait_until_completed(); ``` -------------------------------- ### Install Xcode Command Line Tools Source: https://github.com/yury/cidre/blob/main/_autodocs/configuration.md Install the Xcode command line tools to resolve linker errors. This command should be run in your terminal. ```bash xcode-select --install ``` -------------------------------- ### Minimal Setup for Cidre Source: https://github.com/yury/cidre/blob/main/_autodocs/configuration.md Configure Cidre with minimal features for core foundation functionality. Requires macOS 13.0 or later. ```toml [dependencies] cidre = { version = "0.16", default-features = false, features = ["cf", "macos_13_0"] } ``` -------------------------------- ### Install cargo-box Plugin Source: https://github.com/yury/cidre/blob/main/README.md Install the cargo-box plugin for running tests on iOS devices. Ensure you have Rust and Cargo installed. ```bash cargo install --path ./cargo-box ``` -------------------------------- ### CMTime Example Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/audio-video.md Illustrates how to represent a duration in seconds using the CMTime type with a specific timescale. This example shows the conversion of a rational number to a fractional second value. ```rust Example: CMTimeMake(100, 600) = 100/600 seconds ≈ 0.167 seconds ``` -------------------------------- ### Static String Reference Example Source: https://github.com/yury/cidre/blob/main/README.md Demonstrates creating static string references using the `ns::str!` macro for Objective-C strings. ```rust ns::str!(c"hello") ``` -------------------------------- ### Enable Default Cidre Features Source: https://github.com/yury/cidre/blob/main/_autodocs/configuration.md To enable all default features, including all frameworks and latest OS versions, add the following to your Cargo.toml. This is the simplest way to get started. ```toml [dependencies] cidre = "0.16" # Enables "full" feature ``` -------------------------------- ### Example: Using try_catch for Exception Handling Source: https://github.com/yury/cidre/blob/main/_autodocs/errors.md Demonstrates how to use `try_catch` to execute code that might throw an Objective-C exception and handle the outcome. ```rust use cidre::{ns, arc}; let result = ns::try_catch(|| { // Code that might throw Objective-C exception let s = unsafe { ns::String::with_str("test") }; println!("Created string"); 42 }); match result { Ok(value) => println!("Success: {}", value), Err(exc) => { let reason = exc.reason(); println!("Exception: {:?}", reason); } } ``` -------------------------------- ### Example Usage of try_catch Source: https://github.com/yury/cidre/blob/main/_autodocs/errors.md Demonstrates how to use the `try_catch` function to handle potential Objective-C exceptions. ```APIDOC ## Example Usage of try_catch ### Description This example shows how to use `ns::try_catch` to execute code that might throw an Objective-C exception and handle the result. ### Code Example ```rust use cidre::{ns, arc}; let result = ns::try_catch(|| { // Code that might throw Objective-C exception let s = unsafe { ns::String::with_str("test") }; println!("Created string"); 42 }); match result { Ok(value) => println!("Success: {}", value), Err(exc) => { let reason = exc.reason(); println!("Exception: {:?}", reason); } } ``` ``` -------------------------------- ### Low-level Computation Setup for Cidre Source: https://github.com/yury/cidre/blob/main/_autodocs/configuration.md Enable low-level computation features in Cidre, including 'mtl', 'mps', 'mpsg', 'simd', 'vdsp', and 'cblas'. ```toml [dependencies] cidre = { version = "0.16", features = ["mtl", "mps", "mpsg", "simd", "vdsp", "cblas"] } ``` -------------------------------- ### Rust OS Version Checking Source: https://github.com/yury/cidre/blob/main/_autodocs/README.md Provides examples of checking the operating system version in Rust using `OsVersion::from_str` and the `cidre::version!` macro. This is useful for implementing version-specific logic. ```rust use cidre::api::OsVersion; use std::str::FromStr; if OsVersion::from_str("14.0").unwrap().at_least() { // macOS 14+ specific } if cidre::version!(ios = 16.0) { // iOS 16+ specific } ``` -------------------------------- ### Machine Learning Setup for Cidre Source: https://github.com/yury/cidre/blob/main/_autodocs/configuration.md Configure Cidre for machine learning tasks by enabling 'ml', 'mlc', 'vn', and 'coreml' features. ```toml [dependencies] cidre = { version = "0.16", features = ["ml", "mlc", "vn", "coreml"] } ``` -------------------------------- ### iOS Application Setup for Cidre Source: https://github.com/yury/cidre/blob/main/_autodocs/configuration.md Enable iOS application development features in Cidre, including 'app', 'ui', 'av', 'ar', 'nw', and 'ios_16_0'. ```toml [dependencies] cidre = { version = "0.16", features = ["app", "ui", "av", "ar", "nw", "ios_16_0"] } ``` -------------------------------- ### Example Usage of Blocks Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/core-fundamentals.md Demonstrates creating an escaping block that captures by value and a non-escaping block that borrows a closure. Ensure proper unsafe blocks when dealing with stack-allocated blocks. ```rust use cidre::blocks; // Escaping block capturing by value let block: blocks::EscBlock bool> = blocks::Block::new0(|| true); // Non-escaping block borrowing closure let mut closure = |x: i32| x > 0; let stack_block = unsafe { blocks::Block::stack0(&mut closure) }; ``` -------------------------------- ### Audio/Video Processing Setup for Cidre Source: https://github.com/yury/cidre/blob/main/_autodocs/configuration.md Enable audio and video processing capabilities in Cidre by including the 'av', 'at', 'ca', 'nc', and 'dispatch' features. ```toml [dependencies] cidre = { version = "0.16", features = ["av", "at", "ca", "nc", "dispatch"] } ``` -------------------------------- ### Graphics Development Setup for Cidre Source: https://github.com/yury/cidre/blob/main/_autodocs/configuration.md Configure Cidre for graphics development by enabling 'mtl', 'mtk', 'ca', 'cg', and 'simd' features. ```toml [dependencies] cidre = { version = "0.16", features = ["mtl", "mtk", "ca", "cg", "simd"] } ``` -------------------------------- ### Player Creation and Control Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/audio-video.md Creates and controls media playback. Supports starting, pausing, setting playback rate, and seeking to specific times. It also provides status and error information. ```rust pub struct Player { /* opaque */ } pub enum Status { Unknown, ReadyToPlay, Failed, } pub enum TimeControlStatus { Paused, WaitingToPlayAtSpecifiedRate, Playing, } pub enum ActionAtItemEnd { Advance, Pause, None, } impl Player { pub fn new() -> arc::R; pub fn with_player_item(item: &PlayerItem) -> arc::R; pub fn current_item(&self) -> Option>; pub fn replace_current_item_with_player_item(&mut self, item: Option<&PlayerItem>); // Start playback pub fn play(&mut self); // Pause playback pub fn pause(&mut self); // Playback speed (1.0 = normal) pub fn rate(&self) -> f32; // Set playback speed pub fn set_rate(&mut self, rate: f32); // Current playback position pub fn current_time(&self) -> CMTime; pub fn seek_to_time(&mut self, time: CMTime); pub fn seek_to_time_tolerance(&mut self, time: CMTime, tolerance_before: CMTime, tolerance_after: CMTime); pub fn time_control_status(&self) -> TimeControlStatus; pub fn status(&self) -> Status; pub fn error(&self) -> Option>; } ``` -------------------------------- ### Data Buffer Methods Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/core-foundation.md Documentation for `Data` and `DataMut` structs, which represent immutable and mutable byte buffers respectively. Includes methods for getting the length, byte slice, and raw pointer. ```APIDOC ## Data Buffers ### Description Immutable and mutable byte buffers. ### Methods - `len(&self) -> Index` — Get byte count - `as_slice(&self) -> &[u8]` — Get as byte slice - `as_ptr(&self) -> *const u8` — Get raw pointer ``` -------------------------------- ### Create and Manipulate Foundation Strings Source: https://github.com/yury/cidre/blob/main/_autodocs/README.md Demonstrates creating, manipulating, and joining Foundation strings using `ns::String` and `ns::arr!`. ```rust use cidre::ns; use cidre::arc::Retained; // Create string let s1 = ns::String::with_str("Hello"); let s2 = ns::String::with_str(" World"); // Manipulate if s1.len() > 0 { println!("First: {}", s1.as_str()); } // Collections let arr = ns::arr!(s1, s2); let joined = arr.component_joined_by(&ns::String::with_str(", ")); println!("Joined: {}", joined.as_str()); ``` -------------------------------- ### Get Core Foundation Type ID Description Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/core-foundation.md Provides a function to get the human-readable name for a given Core Foundation `TypeId`. This is useful for debugging and introspection. ```rust pub unsafe fn type_id_desc(type_id: TypeId) -> Option> ``` -------------------------------- ### Core Motion Data Updates Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/additional-frameworks.md Starts and stops the collection of motion sensor data. ```APIDOC ## Core Motion Data Updates ### Description Starts and stops the collection of motion sensor data. ### Methods - `start_device_motion_updates(&mut self)` — Accelerometer + gyro + magnetometer - `start_accelerometer_updates(&mut self)` - `start_gyro_updates(&mut self)` - `start_magnetometer_updates(&mut self)` - `stop_device_motion_updates(&mut self)` ``` -------------------------------- ### Runtime Version Checking with `OsVersion::at_least()` Source: https://github.com/yury/cidre/blob/main/_autodocs/configuration.md Check the operating system version at runtime using `OsVersion::from_str(...).unwrap().at_least()` to enable features available in newer OS versions. ```rust use cidre::api::OsVersion; use std::str::FromStr; if OsVersion::from_str("14.0").unwrap().at_least() { // macOS 14+ specific code println!("Using Sonoma features"); } ``` -------------------------------- ### Core Foundation Type Definition Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/core-foundation.md Defines the base opaque `Type` struct for all Core Foundation objects. It provides common operations like printing debug descriptions, accessing the allocator, checking reference counts, testing equality, getting hash values, retrieving detailed descriptions, and getting the runtime type identifier. ```rust #[repr(transparent)] pub struct Type { /* opaque */ } ``` -------------------------------- ### Bench Build Profile Configuration Source: https://github.com/yury/cidre/blob/main/_autodocs/configuration.md Configure the benchmark build profile to inherit settings from the release profile. ```toml [profile.bench] inherits = "release" ``` -------------------------------- ### TypeId Operations Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/core-foundation.md Provides functionality to get and describe runtime type identifiers for Core Foundation types. ```APIDOC ## TypeId Operations ### Description Provides functionality to get and describe runtime type identifiers for Core Foundation types. ### Methods - `get_type_id(&self) -> TypeId` — Get runtime type identifier (from `Type`) - `type_id() -> TypeId` — Get type ID (type-specific) ### Functions - `unsafe fn type_id_desc(type_id: TypeId) -> Option>` — Get human-readable name for a type ID (e.g., `"CFNumber"`, `"CFString"`). ``` -------------------------------- ### str macro Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/core-foundation.md Creates a static Core Foundation string from a string literal. ```APIDOC ## str macro ### Description Create a static Core Foundation string from a literal. Example: `cf::str!("hello")` produces a `&'static String`. ``` -------------------------------- ### Core Foundation Collections Creation Source: https://github.com/yury/cidre/blob/main/_autodocs/README.md Shows how to create Core Foundation arrays and dictionaries with numbers and strings. ```rust use cidre::cf; use cidre::arc::Retained; // Create array let num1 = cf::Number::from_i32(42); let num2 = cf::Number::from_i32(100); let arr = cf::Array::from_type_refs(&[&num1, &num2])?; println!("Length: {}", arr.len()); // Create dictionary let key = cf::String::from_str_no_copy("name"); let val = cf::String::from_str_no_copy("Alice"); let dict = cf::Dictionary::from_keys_and_values(&[&key], &[&val])?; if let Some(value) = dict.get(&key) { println!("Got: {}", value.as_str()); } ``` -------------------------------- ### Parsing OsVersion from String Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/core-fundamentals.md Demonstrates how to parse OsVersion from string representations like "15", "15.1", or "15.1.2". Requires importing `std::str::FromStr` and `cidre::api::OsVersion`. ```rust use std::str::FromStr; use cidre::api::OsVersion; let v1 = OsVersion::from_str("15").unwrap(); assert_eq!(v1, OsVersion { major: 15, minor: 0, patch: 0 }); let v2 = OsVersion::from_str("15.1").unwrap(); assert_eq!(v2, OsVersion { major: 15, minor: 1, patch: 0 }); let v3 = OsVersion::from_str("15.1.2").unwrap(); assert_eq!(v3, OsVersion { major: 15, minor: 1, patch: 2 }); ``` -------------------------------- ### CMTimeRange Structure for Time Interval Source: https://github.com/yury/cidre/blob/main/_autodocs/types.md Represents a time interval with a start time and a duration. Use CMTimeRange to define segments of media. ```rust pub struct CMTimeRange { pub start: CMTime, pub duration: CMTime, } ``` -------------------------------- ### CMTimeRange Creation Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/audio-video.md Function to create a CMTimeRange, which represents a time range with a start time and a duration. This is useful for defining segments of media. ```rust pub fn CMTimeRangeMake(start: CMTime, duration: CMTime) -> CMTimeRange ``` -------------------------------- ### Configure .box File Source: https://github.com/yury/cidre/blob/main/README.md Create a .box configuration file with your organization ID, development team ID, and device ID for iOS device testing. ```ini BOX_ORG_ID = unique org id, for instance org.cidre (it may be reserved already) DEVELOPMENT_TEAM = team id from step 2 DEVICE_ID = device id from step 3 ``` -------------------------------- ### ProcessInfo Methods Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/foundation.md Retrieves information about the current process and the operating system. ```APIDOC ## ProcessInfo ### Description Current process and system information. ### Methods #### `process_info() -> arc::Rar` - **Returns**: `arc::Rar` - An object containing process information. #### `environment(&self) -> arc::R>` - **Returns**: `arc::R>` - A dictionary of environment variables. #### `operating_system_name(&self) -> arc::Rar` - **Returns**: `arc::Rar` - The name of the operating system. #### `operating_system_version(&self) -> OsVersion` - **Returns**: `OsVersion` - The version of the operating system (major, minor, patch). #### `is_operating_system_at_least_version(&self, major: i32, minor: i32, patch: i32) -> bool` - **Parameters**: - **major** (i32) - The major version number. - **minor** (i32) - The minor version number. - **patch** (i32) - The patch version number. - **Returns**: `bool` - True if the OS version is at least the specified version, false otherwise. #### `process_name(&self) -> arc::Rar` - **Returns**: `arc::Rar` - The name of the current process. #### `process_identifier(&self) -> i32` - **Returns**: `i32` - The process ID. #### `physical_memory(&self) -> u64` - **Returns**: `u64` - The total physical memory in bytes. #### `active_processor_count(&self) -> usize` - **Returns**: `usize` - The number of active processor cores. #### `thermal_state(&self) -> ThermalState` - **Returns**: `ThermalState` - The current thermal state of the system. ``` -------------------------------- ### Async Support for Cidre Source: https://github.com/yury/cidre/blob/main/_autodocs/configuration.md Enable async/await integration for Cidre by including the 'async' feature. This requires the 'blocks' feature (enabled by default) and the 'parking_lot' crate. ```toml [dependencies] cidre = { version = "0.16", features = ["async"] } ``` -------------------------------- ### Capture Session for Input/Output Source: https://github.com/yury/cidre/blob/main/_autodocs/types.md Coordinates audio and video input from devices and output to destinations. Use CaptureSession to manage real-time media capture. ```rust pub struct CaptureSession(ns::Id); ``` -------------------------------- ### RunLoop Methods Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/foundation.md Methods for interacting with the run loop, including getting the current and main run loops, and running the loop until a specific date or indefinitely. ```APIDOC ## RunLoop Methods ### Description Methods for interacting with the run loop, including getting the current and main run loops, and running the loop until a specific date or indefinitely. ### Methods - `current() -> arc::Rar` - `main() -> arc::Rar` - `run(&self)` - `run_until_date(&self, when: &Date) -> bool` - `run_mode_before_date(&self, mode: RunLoopMode, when: &Date) -> bool` ``` -------------------------------- ### Thread Methods Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/foundation.md Provides methods for managing and accessing threads, including getting the current and main threads, and checking if the current thread is the main thread. ```APIDOC ## Thread Methods ### Description Provides methods for managing and accessing threads, including getting the current and main threads, and checking if the current thread is the main thread. ### Methods - `current() -> arc::Rar` — Get current thread - `main() -> arc::Rar` — Get main thread - `is_main_thread() -> bool` - `detach_new_thread_with_block(block: blocks::Block)` ``` -------------------------------- ### Get Last Element of Core Foundation Array Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/core-foundation.md Retrieves a reference to the last element in a Core Foundation `Array`. Returns `Some(&T)` if the array is not empty, otherwise `None`. ```rust pub fn last(&self) -> Option<&T> ``` -------------------------------- ### Get First Element of Core Foundation Array Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/core-foundation.md Retrieves a reference to the first element in a Core Foundation `Array`. Returns `Some(&T)` if the array is not empty, otherwise `None`. ```rust pub fn first(&self) -> Option<&T> ``` -------------------------------- ### AssetExportSession Methods for Configuration and Export Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/audio-video.md Provides methods for configuring and initiating asset export sessions, including setting output details and handling export status. ```rust pub fn with_asset_preset_name(asset: &Asset, preset_name: &String) -> Option> ``` ```rust pub fn output_url(&self) -> Option> ``` ```rust pub fn set_output_url(&mut self, url: &ns::Url) ``` ```rust pub fn output_file_type(&self) -> Option> ``` ```rust pub fn set_output_file_type(&mut self, file_type: &OutputFileType) ``` ```rust pub fn status(&self) -> ExportSessionStatus ``` ```rust pub fn export_as_synchronously_with_completion_handler(&mut self) ``` ```rust pub fn export_as_asynchronously_with_completion_handler(&mut self, handler: blocks::CompletionBlock) ``` ```rust pub fn cancel_export(&mut self) ``` -------------------------------- ### Get Element from Core Foundation Array by Index Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/core-foundation.md Retrieves an element from a Core Foundation `Array` at a specific index. Returns `Some(&T)` if the index is valid, otherwise `None`. ```rust pub fn get(&self, idx: Index) -> Option<&T> ``` -------------------------------- ### CMTimeRangeMake Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/audio-video.md Creates a CMTimeRange value from a start time and a duration. This is used to define a specific segment of time, commonly used for defining clips or sections in media. ```APIDOC ## CMTimeRangeMake ### Description Creates a CMTimeRange value from a start time and a duration. This is used to define a specific segment of time, commonly used for defining clips or sections in media. ### Function Signature `pub fn CMTimeRangeMake(start: CMTime, duration: CMTime) -> CMTimeRange` ### Parameters #### Path Parameters - **start** (CMTime) - Required - The starting CMTime of the range. - **duration** (CMTime) - Required - The duration of the range as a CMTime. ### Return Value - **CMTimeRange** - A CMTimeRange struct representing the specified time segment. ``` -------------------------------- ### CommandBuffer Methods Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/metal-graphics.md Methods for recording and managing GPU commands within a command buffer. ```APIDOC ## CommandBuffer Records GPU commands for execution. ### Methods - `new_render_command_encoder_with_desc(&self, desc: &RenderPassDesc) -> Option>` - `new_blit_command_encoder(&self) -> Option>` — For copy/clear operations - `new_compute_command_encoder(&self) -> Option>` — For compute kernels - `present_drawable(&self, drawable: &Drawable)` — Schedule drawable presentation - `commit(&self)` — Submit commands to GPU - `wait_until_completed(&self)` — Wait for GPU execution - `status(&self) -> CommandBufferStatus` - `error(&self) -> Option` - `gpu_start_time(&self) -> f64` — GPU timestamp - `gpu_end_time(&self) -> f64` — GPU timestamp ``` -------------------------------- ### Runtime Version Checking with `version!` Macro Source: https://github.com/yury/cidre/blob/main/_autodocs/configuration.md Use the `cidre::version!` macro for concise runtime checks against specific OS versions. ```rust if cidre::version!(macos = 14.0) { // macOS 14+ code } if cidre::version!(ios = 16.0, tvos = 16.0) { // iOS or tvOS 16+ code } ``` -------------------------------- ### Get Core Foundation String Length Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/core-foundation.md Retrieves the length of a Core Foundation `String` in characters, not bytes. Use this to determine the number of Unicode code points in the string. ```rust pub fn len(&self) -> Index ``` -------------------------------- ### Device Methods Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/metal-graphics.md Methods for interacting with the GPU device, including checking format support, creating command queues, buffers, textures, and shader libraries. ```APIDOC ## Device Represents the GPU and its capabilities. ### Methods - `is_texture_format_supported(format: PixelFormat) -> bool` — Check format support - `new_command_queue(&self) -> Option>` — Create queue for submitting work - `new_buffer_with_bytes(&self, bytes: &[u8], options: ResourceOpts) -> arc::R` — Create GPU buffer from data - `new_buffer_with_length(&self, len: usize, options: ResourceOpts) -> arc::R` — Create empty buffer - `new_texture_with_desc(&self, desc: &TextureDesc) -> Option>` — Create texture - `new_library_with_source(src: &String, opts: &CompileOpts) -> Result>` — Compile shader code - `new_library_with_file(path: &String) -> Result>` — Load compiled shader library - `new_render_pipeline_state_with_desc(&self, desc: &RenderPipelineDesc) -> Result>` — Create render pipeline ``` -------------------------------- ### Get All Values from Core Foundation Dictionary Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/core-foundation.md Retrieves all values present in a Core Foundation `Dictionary` as a new `Array`. This allows iteration or processing of all values stored in the dictionary. ```rust pub fn values(&self) -> arc::R> ``` -------------------------------- ### OsVersion Methods Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/core-fundamentals.md Provides methods to check OS version compatibility against specific platform versions. ```APIDOC ## OsVersion Represents a semantic version triplet matching Apple platform versions. ### Methods - `at_least(&self) -> bool` - Check if current platform meets this version. - Platform determined by target triple: `#[cfg(target_os = "...")]` - Returns `false` on incompatible platform. - `platform_at_least(&self, platform: Platform) -> bool` - Check against specific platform. ``` -------------------------------- ### init_with_default! Macro Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/core-fundamentals.md Generates an initializer function for ClassInstExtra when the inner type implements Default. ```APIDOC ## Macro `init_with_default!` ### Description Generate an initializer function for `ClassInstExtra` when `InnerType: Default`. ``` -------------------------------- ### Get All Keys from Core Foundation Dictionary Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/core-foundation.md Retrieves all keys present in a Core Foundation `Dictionary` as a new `Array`. This allows iteration or processing of all keys stored in the dictionary. ```rust pub fn keys(&self) -> arc::R> ``` -------------------------------- ### Async Blocks with Dispatch Source: https://github.com/yury/cidre/blob/main/_autodocs/README.md Demonstrates dispatching a block to a background queue for asynchronous execution. ```rust #[cfg(feature = "async")] use cidre::{blocks, dispatch}; // Create work block let block = blocks::Block::new0(|| { println!("Running on background thread"); }); // Dispatch to background queue let queue = dispatch::Queue::global(dispatch::QOS::Background); queue.async_f(&block); ``` -------------------------------- ### Get Value from Core Foundation Dictionary by Key Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/core-foundation.md Retrieves the value associated with a specific key in a Core Foundation `Dictionary`. Returns `Some(&V)` if the key exists, otherwise `None`. ```rust pub fn get(&self, key: &K) -> Option<&V> ``` -------------------------------- ### Release Build Profile Configuration Source: https://github.com/yury/cidre/blob/main/_autodocs/configuration.md Configure the release build profile for optimizations like Link Time Optimization (LTO) and panic behavior. ```toml [profile.release] lto = true panic = "abort" ``` -------------------------------- ### Date and Time Interval Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/core-foundation.md Details the `Date` struct and `TimeInterval` type, used to represent moments in time. Includes constants for time intervals and a method to get the current absolute time. ```APIDOC ## Date ### Description Represents a moment in time as seconds since a reference date. ### Constants - `ABS_TIME_INTERVAL_SINCE_1904: TimeInterval` - `ABS_TIME_INTERVAL_SINCE_1970: TimeInterval` ### Methods - `abs_time_current() -> TimeInterval` — Get current time ``` -------------------------------- ### Url Methods Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/core-foundation.md Provides methods for creating and inspecting Uniform Resource Locators. ```APIDOC ## Url ### Description Wrapper for Uniform Resource Locator. ### Methods - `create_with_string(s: &str) -> Option>`: Creates a Url from a string slice. - `as_str(&self) -> &str`: Returns the Url as a string slice. - `scheme(&self) -> Option>`: Gets the scheme of the Url. - `host(&self) -> Option>`: Gets the host of the Url. - `path(&self) -> Option>`: Gets the path of the Url. ``` -------------------------------- ### Threading with Blocks on Main Thread Source: https://github.com/yury/cidre/blob/main/_autodocs/README.md Shows how to execute a block of code on the main dispatch queue. ```rust use cidre::{blocks, ns}; // Create work block let block = blocks::Block::new0(|| { println!("Executing work"); }); // Run on main thread let main_queue = dispatch::Queue::main(); main_queue.async_f(&block); ``` -------------------------------- ### Core Foundation Null Type Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/core-foundation.md Represents the Core Foundation `kCFNull` singleton, which is the null value. It provides methods to get its type ID, access the singleton instance, and bridge to Foundation's `ns::Null`. ```rust pub struct Null(Type); ``` -------------------------------- ### AVFoundation Video Playback Control Source: https://github.com/yury/cidre/blob/main/_autodocs/README.md Demonstrates creating an AVFoundation player, controlling playback, and checking the current time. ```rust use cidre::av; use cidre::ns; // Create player with URL let url = ns::Url::file_url_with_path("/path/to/video.mp4"); let item = av::PlayerItem::with_url(&url); let player = av::Player::with_player_item(&item); // Control playback player.play(); std::thread::sleep(std::time::Duration::from_secs(5)); player.pause(); // Check status let time = player.current_time(); println!("Current time: {:.2}s", av::CMTimeGetSeconds(time)); ``` -------------------------------- ### Core Motion DeviceMotion Methods Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/additional-frameworks.md Provides detailed information about the device's motion state. ```APIDOC ## Core Motion DeviceMotion Methods ### Description Provides detailed information about the device's motion state. ### Methods - `attitude(&self) -> arc::Rar` — Roll, pitch, yaw - `gravity(&self) -> (f64, f64, f64)` — Gravity vector - `user_acceleration(&self) -> CMAcceleration` — Acceleration minus gravity - `rotation_rate(&self) -> CMRotationRate` — Angular velocity ``` -------------------------------- ### Usage of ns::Result Source: https://github.com/yury/cidre/blob/main/_autodocs/errors.md Illustrates how to use the `ns::Result` type for operations that can succeed with a value or fail with a borrowed error. The second example shows how to ensure the error reference's lifetime matches the function's scope. ```rust pub fn risky_operation() -> ns::Result { // ... } pub fn returns_error_ref(err: &ns::Error) -> ns::Result<'_> { // Error reference lives for the function's scope } ``` -------------------------------- ### Cidre Exception Handling Functions Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/foundation.md Provides functions to set and get the uncaught exception handler, and to safely execute code that might throw an Objective-C exception. Use `try_catch` for functions returning a value and `try_catch_err` for functions with no return value. ```rust pub fn set_uncaught_exception_handler(handler: UncaughtExceptionHandler) pub fn uncaught_exception_handler() -> Option pub fn try_catch(f: F) -> std::result::Result> where F: FnOnce() -> R pub fn try_catch_err(f: F) -> std::result::Result<(), arc::R> where F: FnOnce() ``` -------------------------------- ### Define ProcessInfo structures Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/foundation.md Defines structures for retrieving current process and system information, including ProcessInfo, OsVersion, and ThermalState. ```rust pub struct ProcessInfo { /* opaque */ } pub struct OsVersion { major: i32, minor: i32, patch: i32 } pub enum ThermalState { Critical, Nominal, Serious, Thermal, } ``` -------------------------------- ### init_with_default! Macro Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/core-fundamentals.md Generates an initializer for `ClassInstExtra` when the inner type implements `Default`. ```rust macro_rules! init_with_default { ($NewType:ty, $InnerType:ty) => { ... }; } ``` -------------------------------- ### Low-level Core Foundation String Creation Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/core-foundation.md Provides a low-level method to create a Core Foundation `String` from a byte slice with a specified encoding. Allows control over memory deallocation and allocator. ```rust pub fn create_with_bytes_no_copy_in(bytes: &[u8], encoding: Encoding, deallocate: bool, allocator: &Allocator) -> Option> ``` -------------------------------- ### log macro Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/foundation.md Logs a message to the system console. Arguments are formatted similarly to `println!`. ```APIDOC ## log macro ### Description Logs a message to the system console. Arguments formatted like `println!`. ### Syntax ```rust pub macro log($($arg:tt)*) ``` ### Example ```rust cidre::log!("value: {}", 42); ``` ``` -------------------------------- ### Create Static Core Foundation String with Macro Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/core-foundation.md Creates a static Core Foundation string literal using the `str!` macro. This is a convenient way to define compile-time constant strings. ```rust macro_rules! str { ($s:expr) => { /* static CFString */ }; } ``` -------------------------------- ### Log a message using the log macro Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/foundation.md Use the `log!` macro to output messages to the system console. Arguments are formatted similarly to `println!`. ```rust pub macro log($($arg:tt)*) ``` ```rust cidre::log!("value: {}", 42); ``` -------------------------------- ### CommandQueue Methods Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/metal-graphics.md Methods for managing command queues, used to submit command buffers for GPU execution. ```APIDOC ## CommandQueue Queue for submitting command buffers to the GPU. ### Methods - `new_command_buffer(&self) -> Option>` — Create buffer for recording commands - `command_buffer_with_unretained_references(&self) -> Option>` — Create buffer without reference tracking ``` -------------------------------- ### Development Build Profile Configuration Source: https://github.com/yury/cidre/blob/main/_autodocs/configuration.md Configure the development build profile for faster compilation with a lower optimization level. ```toml [profile.dev] opt-level = 1 ``` -------------------------------- ### Core Motion Manager Initialization Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/additional-frameworks.md Initializes the MotionManager to access motion sensor data. ```APIDOC ## Core Motion Manager Initialization ### Description Initializes the MotionManager to access motion sensor data. ### Methods - `new() -> arc::R` ``` -------------------------------- ### ComparisonResult Source: https://github.com/yury/cidre/blob/main/_autodocs/types.md Comparison result convertible to `std::cmp::Ordering` via `Into`. ```APIDOC ## ComparisonResult ### Description Comparison result convertible to `std::cmp::Ordering` via `Into`. ### Enum ```rust #[repr(isize)] pub enum ComparisonResult { LessThen = -1, EqualTo = 0, GreaterThen = 1, } ``` ``` -------------------------------- ### CompileOpts Struct and Optimization Level Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/metal-graphics.md Defines shader compilation options, including fast math and language version. ```rust pub struct CompileOpts { /* opaque */ } pub enum OptimizationLevel { Default, None, Size, Performance, } - set_fast_math_enabled(&mut self, enabled: bool) - set_language_version(&mut self, version: LanguageVersion) ``` -------------------------------- ### Audio Buffer and Buffer List Structures Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/audio-video.md Defines structures for holding audio sample data and managing multiple audio buffers. ```rust pub struct AudioBuffer { pub number_of_channels: u32, pub data_byte_size: u32, pub data: *mut u8, } pub struct AudioBufferList { pub number_buffers: u32, pub buffers: [AudioBuffer; 1], } ``` -------------------------------- ### Capture Input Source Source: https://github.com/yury/cidre/blob/main/_autodocs/types.md Abstracts various sources for captured media, such as devices, images, or files. Use CaptureInput as a base for specific input types. ```rust pub struct CaptureInput(ns::Id); ``` -------------------------------- ### DlSym Methods Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/core-fundamentals.md Enables dynamic loading and caching of framework symbols (functions and variables). ```APIDOC ## DlSym Dynamic symbol loader for lazily-loaded framework symbols. Uses thread-safe caching with acquire/release semantics. ### Methods - `const fn new(name: &'static CStr) -> Self` - Create loader for symbol. - `get_fn(&self) -> Option<&T>` - Load and cache function pointer. - `get_var(&self) -> Option<&T>` - Load and cache variable pointer. Returns `None` if symbol not available (weak linking support). ``` -------------------------------- ### Game Controller Methods Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/additional-frameworks.md Provides methods for interacting with game controllers, retrieving controller information, and accessing gamepad inputs. ```APIDOC ## Controller Methods ### Description Provides methods for interacting with game controllers, retrieving controller information, and accessing gamepad inputs. ### Methods - `controllers() -> arc::R>`: Retrieves a list of available controllers. - `current_controller() -> Option>`: Gets the currently active controller. - `gamepad(&self) -> Option>`: Retrieves the gamepad associated with the controller. - `extended_gamepad(&self) -> Option>`: Retrieves the extended gamepad information. - `vendor(&self) -> Option>`: Gets the vendor name of the controller. - `player_index(&self) -> PlayerIndex`: Returns the player index assigned to the controller. - `set_player_index(&mut self, index: PlayerIndex)`: Sets the player index for the controller. ``` -------------------------------- ### URL Structure and Path Styles Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/core-foundation.md Defines the URL structure and its associated path styles. ```rust pub struct Url(Type); pub enum PathStyle { Default, Posix, Windows, } ``` -------------------------------- ### Security Framework Key Methods Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/additional-frameworks.md Methods for managing and inspecting cryptographic keys. ```APIDOC ## Security Framework - Key Methods ### Description Operations related to cryptographic keys within the Security Framework. ### Methods - `copy_attributes(&self) -> Option>` - Copies the attributes associated with the key. - `get_block_size(&self) -> usize` - Returns the block size of the key. ``` -------------------------------- ### Iterate Core Foundation Dictionary Key-Value Pairs Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/core-foundation.md Applies a callback function to each key-value pair in a Core Foundation `Dictionary`. The `ApplierFn` receives the key, value, and a context pointer for processing. ```rust pub fn apply(&self, fn: ApplierFn, context: *mut c_void) ``` -------------------------------- ### Core Media (CM) Time Utility Functions Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/audio-video.md Provides utility functions for creating and converting `CMTime` values. ```rust pub fn CMTimeMake(value: i64, timescale: i32) -> CMTime ``` ```rust pub fn CMTimeGetSeconds(time: CMTime) -> f64 ``` ```rust pub fn CMTimeMakeWithSeconds(seconds: f64, preferred_timescale: i32) -> CMTime ``` -------------------------------- ### Cargo Metadata for Docs.rs Source: https://github.com/yury/cidre/blob/main/_autodocs/configuration.md Configure package metadata for docs.rs, specifying the default target and available features/targets for documentation builds. ```toml [package.metadata.docs.rs] default-target = "aarch64-apple-darwin" features = ["full"] targets = [ "aarch64-apple-darwin", "aarch64-apple-ios", "aarch64-apple-tvos", "aarch64-apple-watchos", "aarch64-apple-visionos", ] ``` -------------------------------- ### Error Recovery Pattern Source: https://github.com/yury/cidre/blob/main/_autodocs/errors.md Demonstrates how to recover from specific errors, such as 'File not found', by performing recovery actions and retrying the operation. ```rust use cidre::ns; match some_operation() { Ok(value) => process_success(value), Err(err) => { if err.code() == 4 { // File not found create_default_file()?; retry_operation() } else { Err(format!("Failed: {}", err.localized_description().as_str()).into()) } } } ``` -------------------------------- ### version! Macro Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/core-fundamentals.md A compile-time macro for version checking that expands to runtime predicates, simplifying conditional code execution based on platform versions. ```APIDOC ## version! Macro Compile-time version checking that expands to runtime predicates. Returns `true` if current platform meets any specified version requirement. ### Examples: ```rust if cidre::version!(macos = 15.0) { // macOS 15+ specific code } if cidre::version!(ios = 17.0, macos = 13.0) { // iOS 17+ OR macOS 13+ code } ``` ``` -------------------------------- ### Network Framework - Path Monitoring Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/additional-frameworks.md Enables monitoring of network path changes, including interface status and cost. ```APIDOC ## Network Framework - Path Monitoring ### Description Monitors network path changes and provides information about the network path's status, cost, and available interfaces. ### Methods on PathMonitor - `new() -> arc::R`: Creates a new PathMonitor. - `set_update_handler(&mut self, handler: blocks::Block)`: Sets the handler to be called when the path updates. - `start(&mut self, queue: &dispatch::Queue)`: Starts monitoring the network path. - `cancel(&mut self)`: Cancels the path monitoring. ### Methods on Path - `status(&self) -> Status`: Returns the status of the network path. - `is_expensive(&self) -> bool`: Checks if the network path is expensive (e.g., cellular). - `available_interfaces(&self) -> arc::R>`: Returns a list of available network interfaces. - `uses_interface_type(&self, interface_type: InterfaceType) -> bool`: Checks if the path uses a specific interface type. ``` -------------------------------- ### Manual Framework Linking Source: https://github.com/yury/cidre/blob/main/_autodocs/configuration.md Manually link frameworks using the `#[link(name = "...", kind = "framework")]` attribute when automatic linking is insufficient. ```rust #[link(name = "CoreFoundation", kind = "framework")] unsafe extern "C" {} #[link(name = "Foundation", kind = "framework")] #[link(name = "Metal", kind = "framework")] #[link(name = "MetalKit", kind = "framework")] ``` -------------------------------- ### Color Creation Methods Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/metal-graphics.md Methods for creating Color objects in different color spaces. ```APIDOC ## Color Creation Methods ### Description Methods for creating `Color` objects using different color spaces. ### Methods - `create_with_generic_gray_colorspace(gray: f64, alpha: f64) -> arc::R`: Creates a color using generic grayscale. - `create_with_generic_rgb_colorspace(red: f64, green: f64, blue: f64, alpha: f64) -> arc::R`: Creates a color using generic RGB. ``` -------------------------------- ### Output File Type Enumeration Source: https://github.com/yury/cidre/blob/main/_autodocs/types.md Specifies the desired output file format for media exports. Use OutputFileType to select the format like QuickTime, MPEG4, etc. ```rust pub enum OutputFileType { QuickTimeMovie, MPEG4, AppleM4A, ThreeGPP, ThreeGPP2, MobileInterchange, AVType, } ``` -------------------------------- ### FileManager Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/foundation.md Provides methods for performing file system operations such as creating, deleting, and moving files and directories. ```APIDOC ## FileManager ### Description File system operations. ### Methods - `default_manager() -> arc::Rar` — Get the shared file manager instance. - `contents_of_directory_at_url(&self, url: &Url) -> Result>>` — Get the contents of a directory at a given URL. - `contents_of_directory_at_path(&self, path: &str) -> Result>>` — Get the contents of a directory at a given path. - `create_directory_at_url(&self, url: &Url, intermediate: bool, properties: Option<&Dictionary>) -> Result<()>` — Create a directory at the specified URL. - `file_exists_at_path(&self, path: &str) -> bool` — Check if a file or directory exists at the given path. - `remove_item_at_url(&self, url: &Url) -> Result<()>` — Remove an item at the specified URL. - `move_item_at_url_to_url(&self, src: &Url, dst: &Url) -> Result<()>` — Move an item from a source URL to a destination URL. - `copy_item_at_url_to_url(&self, src: &Url, dst: &Url) -> Result<()>` — Copy an item from a source URL to a destination URL. - `attributes_of_item_at_path(&self, path: &str) -> Result>>` — Get the attributes of a file or directory at the specified path. ``` -------------------------------- ### Library Structure Source: https://github.com/yury/cidre/blob/main/_autodocs/types.md Represents a collection of compiled shaders. ```rust pub struct Library(ns::Id); ``` -------------------------------- ### CommandQueue Structure Source: https://github.com/yury/cidre/blob/main/_autodocs/types.md Represents a queue for submitting GPU commands. ```rust pub struct CommandQueue(ns::Id); ``` -------------------------------- ### Device Structure Source: https://github.com/yury/cidre/blob/main/_autodocs/types.md Represents the GPU device and capability controller. ```rust pub struct Device(ns::Id); ``` -------------------------------- ### Core Audio Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/audio-video.md Provides interfaces for device enumeration and property management for audio I/O using the Audio Hardware Abstraction Layer (HAL). ```APIDOC ## Core Audio ### Description Provides interfaces for device enumeration and property management for audio I/O using the Audio Hardware Abstraction Layer (HAL). ### Functions - `AudioObjectGetPropertyDataSize(object_id: AudioObjectId, addr: &AudioObjectPropertyAddr, out_size: &mut u32) -> Status`: Gets the size of the property data for an audio object. - `AudioObjectGetPropertyData(object_id: AudioObjectId, addr: &AudioObjectPropertyAddr, in_qualifier_data_size: u32, in_qualifier_data: *const u8, io_data_size: &mut u32, out_data: *mut u8) -> Status`: Retrieves property data for an audio object. ### Types - `AudioObjectId(u32)`: Represents a unique identifier for an audio object. ``` -------------------------------- ### Path Utilities Functions Source: https://github.com/yury/cidre/blob/main/_autodocs/api-reference/foundation.md Provides utility functions for accessing common directory paths like home and temporary directories, as well as user names. ```rust pub fn home_dir() -> arc::Rar pub fn home_dir_for_user(username: &String) -> Option> pub fn tmp_dir() -> arc::Rar pub fn user_name() -> arc::Rar pub fn full_user_name() -> arc::Rar pub fn search_path_for_dirs_in_domains( dir: SearchPathDirectory, domain: SearchPathDomainMask, ) -> arc::R> ```