prism_sys/lib.rs
1//! Raw FFI bindings to prism (<https://github.com/ethindp/prism>), a
2//! platform-agnostic speech and screen reader output library.
3#![no_std]
4#![allow(non_camel_case_types)]
5
6use core::ffi::{c_char, c_int, c_void};
7
8/// An opaque prism context, holding a backend registry.
9#[repr(C)]
10#[derive(Debug)]
11pub struct PrismContext {
12 _opaque: [u8; 0],
13}
14
15/// An opaque backend instance obtained from a registry.
16#[repr(C)]
17#[derive(Debug)]
18pub struct PrismBackend {
19 _opaque: [u8; 0],
20}
21
22/// An opaque, immutable set of backend registrations.
23#[repr(C)]
24#[derive(Debug)]
25pub struct PrismRegistry {
26 _opaque: [u8; 0],
27}
28
29/// An opaque, mutable collection of backend registrations.
30#[repr(C)]
31#[derive(Debug)]
32pub struct PrismRegistryBuilder {
33 _opaque: [u8; 0],
34}
35
36/// A backend's identifier, derived from its name.
37pub type PrismBackendId = u64;
38/// An error code. `PRISM_OK` means success; every other value is a failure.
39pub type PrismError = c_int;
40/// The severity of a log message, or a threshold for delivering them.
41pub type PrismLogLevel = c_int;
42
43/// Channel count was retrieved.
44pub const PRISM_OK: PrismError = 0;
45/// The backend has not been initialized.
46pub const PRISM_ERROR_NOT_INITIALIZED: PrismError = 1;
47/// The vtable's `size` member was zero, the declared feature set was inconsistent with the vtable, or the priority value was negative.
48pub const PRISM_ERROR_INVALID_PARAM: PrismError = 2;
49/// The backend does not support audio format queries.
50pub const PRISM_ERROR_NOT_IMPLEMENTED: PrismError = 3;
51/// No voices are available for this backend
52pub const PRISM_ERROR_NO_VOICES: PrismError = 4;
53/// The specified voice was not found
54pub const PRISM_ERROR_VOICE_NOT_FOUND: PrismError = 5;
55/// Speech synthesis failed.
56pub const PRISM_ERROR_SPEAK_FAILURE: PrismError = 6;
57/// Memory allocation failed during initialization.
58pub const PRISM_ERROR_MEMORY_FAILURE: PrismError = 7;
59/// A parameter value exceeded its valid range
60pub const PRISM_ERROR_RANGE_OUT_OF_BOUNDS: PrismError = 8;
61/// An internal error occurred during initialization.
62pub const PRISM_ERROR_INTERNAL: PrismError = 9;
63/// No speech is currently playing.
64pub const PRISM_ERROR_NOT_SPEAKING: PrismError = 10;
65/// Speech is not currently paused.
66pub const PRISM_ERROR_NOT_PAUSED: PrismError = 11;
67/// Speech is already paused.
68pub const PRISM_ERROR_ALREADY_PAUSED: PrismError = 12;
69/// `text` contains invalid UTF-8 sequences.
70pub const PRISM_ERROR_INVALID_UTF8: PrismError = 13;
71/// The builder is spent, or a backend with the same name or the same identifier is already present in the builder.
72pub const PRISM_ERROR_INVALID_OPERATION: PrismError = 14;
73/// The backend was already initialized.
74pub const PRISM_ERROR_ALREADY_INITIALIZED: PrismError = 15;
75/// The backend's underlying system component is unavailable.
76pub const PRISM_ERROR_BACKEND_NOT_AVAILABLE: PrismError = 16;
77/// An unspecified error occurred.
78pub const PRISM_ERROR_UNKNOWN: PrismError = 17;
79/// The audio format which the underlying engine returned to Prism cannot be understood by Prism, or it's parameters are nonsensical.
80pub const PRISM_ERROR_INVALID_AUDIO_FORMAT: PrismError = 18;
81/// The backend possesses an internal hard ceiling as to how many instances may be instantiated at any given time, and this limit would be exceeded were another to be initialized.
82pub const PRISM_ERROR_INTERNAL_BACKEND_LIMIT_EXCEEDED: PrismError = 19;
83/// An error occured when the backend was executing a function which has caused the backend to enter an undefined state. The caller should re-initialize the backend from scratch.
84pub const PRISM_ERROR_BACKEND_ENTERED_UNDEFINED_STATE: PrismError = 20;
85/// A shared library could not be opened, because no file exists at the given path, it is not a loadable image, it was built for a different architecture, or its initialization code failed
86pub const PRISM_ERROR_LIBRARY_LOAD_FAILED: PrismError = 21;
87/// A shared library was opened but does not export the plugin entry point
88pub const PRISM_ERROR_LIBRARY_INVALID: PrismError = 22;
89/// A plugin declined the host, or a backend descriptor declared an ABI generation this build of Prism does not accept
90pub const PRISM_ERROR_INCOMPATIBLE_ABI: PrismError = 23;
91/// The number of defined error codes. Not itself an error.
92pub const PRISM_ERROR_COUNT: PrismError = 24;
93
94/// The most verbose level, used for fine-grained tracing of internal operations.
95pub const PRISM_LOG_LEVEL_TRACE: PrismLogLevel = 0;
96/// Diagnostic information useful during development.
97pub const PRISM_LOG_LEVEL_DEBUG: PrismLogLevel = 1;
98/// Informational messages describing normal operation.
99pub const PRISM_LOG_LEVEL_INFO: PrismLogLevel = 2;
100/// Conditions that are not errors but MAY indicate a problem.
101pub const PRISM_LOG_LEVEL_WARN: PrismLogLevel = 3;
102/// Error conditions.
103pub const PRISM_LOG_LEVEL_ERROR: PrismLogLevel = 4;
104/// Not a message severity. When supplied to `prism_set_log_level`, it suppresses all messages, since no message has a severity greater than or equal to it.
105pub const PRISM_LOG_LEVEL_NONE: PrismLogLevel = 5;
106
107/// The underlying engine or service is available. This determination is advisory; `prism_backend_initialize` MAY still fail.
108pub const PRISM_BACKEND_IS_SUPPORTED_AT_RUNTIME: u64 = 1 << 0;
109/// `prism_backend_speak` is implemented.
110pub const PRISM_BACKEND_SUPPORTS_SPEAK: u64 = 1 << 2;
111/// `prism_backend_speak_to_memory` is implemented.
112pub const PRISM_BACKEND_SUPPORTS_SPEAK_TO_MEMORY: u64 = 1 << 3;
113/// `prism_backend_braille` is implemented.
114pub const PRISM_BACKEND_SUPPORTS_BRAILLE: u64 = 1 << 4;
115/// `prism_backend_output` is implemented.
116pub const PRISM_BACKEND_SUPPORTS_OUTPUT: u64 = 1 << 5;
117/// `prism_backend_is_speaking` is implemented.
118pub const PRISM_BACKEND_SUPPORTS_IS_SPEAKING: u64 = 1 << 6;
119/// `prism_backend_stop` is implemented.
120pub const PRISM_BACKEND_SUPPORTS_STOP: u64 = 1 << 7;
121/// `prism_backend_pause` is implemented.
122pub const PRISM_BACKEND_SUPPORTS_PAUSE: u64 = 1 << 8;
123/// `prism_backend_resume` is implemented.
124pub const PRISM_BACKEND_SUPPORTS_RESUME: u64 = 1 << 9;
125/// `prism_backend_set_volume` is implemented.
126pub const PRISM_BACKEND_SUPPORTS_SET_VOLUME: u64 = 1 << 10;
127/// `prism_backend_get_volume` is implemented.
128pub const PRISM_BACKEND_SUPPORTS_GET_VOLUME: u64 = 1 << 11;
129/// `prism_backend_set_rate` is implemented.
130pub const PRISM_BACKEND_SUPPORTS_SET_RATE: u64 = 1 << 12;
131/// `prism_backend_get_rate` is implemented.
132pub const PRISM_BACKEND_SUPPORTS_GET_RATE: u64 = 1 << 13;
133/// `prism_backend_set_pitch` is implemented.
134pub const PRISM_BACKEND_SUPPORTS_SET_PITCH: u64 = 1 << 14;
135/// `prism_backend_get_pitch` is implemented.
136pub const PRISM_BACKEND_SUPPORTS_GET_PITCH: u64 = 1 << 15;
137/// `prism_backend_refresh_voices` is implemented.
138pub const PRISM_BACKEND_SUPPORTS_REFRESH_VOICES: u64 = 1 << 16;
139/// `prism_backend_count_voices` is implemented.
140pub const PRISM_BACKEND_SUPPORTS_COUNT_VOICES: u64 = 1 << 17;
141/// `prism_backend_get_voice_name` is implemented.
142pub const PRISM_BACKEND_SUPPORTS_GET_VOICE_NAME: u64 = 1 << 18;
143/// `prism_backend_get_voice_language` is implemented.
144pub const PRISM_BACKEND_SUPPORTS_GET_VOICE_LANGUAGE: u64 = 1 << 19;
145/// `prism_backend_get_voice` is implemented.
146pub const PRISM_BACKEND_SUPPORTS_GET_VOICE: u64 = 1 << 20;
147/// `prism_backend_set_voice` is implemented.
148pub const PRISM_BACKEND_SUPPORTS_SET_VOICE: u64 = 1 << 21;
149/// `prism_backend_get_channels` is implemented.
150pub const PRISM_BACKEND_SUPPORTS_GET_CHANNELS: u64 = 1 << 22;
151/// `prism_backend_get_sample_rate` is implemented.
152pub const PRISM_BACKEND_SUPPORTS_GET_SAMPLE_RATE: u64 = 1 << 23;
153/// `prism_backend_get_bit_depth` is implemented.
154pub const PRISM_BACKEND_SUPPORTS_GET_BIT_DEPTH: u64 = 1 << 24;
155/// Reserved.
156pub const PRISM_BACKEND_PERFORMS_SILENCE_TRIMMING_ON_SPEAK: u64 = 1 << 25;
157/// The backend trims leading and trailing silence from the audio stream before delivering it to the audio callback.
158pub const PRISM_BACKEND_PERFORMS_SILENCE_TRIMMING_ON_SPEAK_TO_MEMORY: u64 = 1 << 26;
159/// Reserved.
160pub const PRISM_BACKEND_SUPPORTS_SPEAK_SSML: u64 = 1 << 27;
161/// Reserved.
162pub const PRISM_BACKEND_SUPPORTS_SPEAK_TO_MEMORY_SSML: u64 = 1 << 28;
163/// The highest bit reserved for feature flags.
164pub const PRISM_BACKEND_FEATURE_MAX_BIT: u64 = 1 << 63;
165
166/// Invalid/sentinel value (always 0)
167pub const PRISM_BACKEND_INVALID: PrismBackendId = 0;
168/// Microsoft SAPI (Windows)
169pub const PRISM_BACKEND_SAPI: PrismBackendId = 0x1D6D_F724_22CE_EE66;
170/// `AVSpeechSynthesizer` (macOS, iOS, tvOS, `WatchOS`, `VisionOS`)
171pub const PRISM_BACKEND_AV_SPEECH: PrismBackendId = 0x28E3_4295_7780_5C24;
172/// `VoiceOver` screen reader (macOS, `MacCatalyst`, iOS, `WatchOS`, tvOS, `VisionOS`)
173pub const PRISM_BACKEND_VOICE_OVER: PrismBackendId = 0xCB48_9796_1A75_4BCB;
174/// Speech Dispatcher (Linux/BSD, win32 via Wine)
175pub const PRISM_BACKEND_SPEECH_DISPATCHER: PrismBackendId = 0xE3D6_F895_D949_EBFE;
176/// NVDA screen reader (Windows)
177pub const PRISM_BACKEND_NVDA: PrismBackendId = 0x89CC_19C5_C4AC_1A56;
178/// JAWS screen reader (Windows)
179pub const PRISM_BACKEND_JAWS: PrismBackendId = 0xAC3D_60E9_BD84_B53E;
180/// Windows `OneCore` speech API (Windows 10+)
181pub const PRISM_BACKEND_ONE_CORE: PrismBackendId = 0x6797_D32F_0D99_4CB4;
182/// Orca screen reader (Linux/BSD, win32 via Wine)
183pub const PRISM_BACKEND_ORCA: PrismBackendId = 0x10AA_1FC0_5A17_F96C;
184/// Android screen readers (Android)
185pub const PRISM_BACKEND_ANDROID_SCREEN_READER: PrismBackendId = 0xD199_C175_AEEC_494B;
186/// Android TTS engine (Android)
187pub const PRISM_BACKEND_ANDROID_TTS: PrismBackendId = 0xBC17_5831_BFE4_E5CC;
188/// Web `SpeechSynthesis` API (web)
189pub const PRISM_BACKEND_WEB_SPEECH: PrismBackendId = 0x3572_538D_44D4_4A8F;
190/// `UIAutomation` backend (Windows only)
191pub const PRISM_BACKEND_UIA: PrismBackendId = 0x6238_F019_DB67_8F8E;
192/// Zhengdu Screen Reader (Windows)
193pub const PRISM_BACKEND_ZDSR: PrismBackendId = 0x3D93_C56C_9E7F_2A2E;
194/// `ZoomText` (Windows)
195pub const PRISM_BACKEND_ZOOM_TEXT: PrismBackendId = 0xAE43_9D62_DC7B_1479;
196/// `BoyPCReader` (windows only)
197pub const PRISM_BACKEND_BOY_PC_READER: PrismBackendId = 0x285A_BA1C_16F3_300F;
198/// `PCTalker` (windows only)
199pub const PRISM_BACKEND_PC_TALKER: PrismBackendId = 0x344B_9519_62E3_B835;
200/// Sense Reader screen reader (Windows)
201pub const PRISM_BACKEND_SENSE_READER: PrismBackendId = 0xED47_6089_0B55_C2F2;
202/// `SystemAccess` screen reader (windows) (only available if explicitly enabled at build time)
203pub const PRISM_BACKEND_SYSTEM_ACCESS: PrismBackendId = 0x8380_F2A3_7B2C_3EB6;
204/// `WindowEyes` screen reader (windows) (only available if explicitly enabled at build time)
205pub const PRISM_BACKEND_WINDOW_EYES: PrismBackendId = 0x9120_D899_0878_5C13;
206/// Spiel (Linux and BSDs only)
207pub const PRISM_BACKEND_SPIEL: PrismBackendId = 0x478B_44F1_4AD3_D89C;
208
209/// The `PrismConfig` layout version this binding describes.
210pub const PRISM_CONFIG_VERSION: u8 = 4;
211/// The plugin ABI generation this binding describes.
212pub const PRISM_PLUGIN_ABI_VERSION: u64 = 1;
213
214/// The type of a function invoked when a backend's runtime availability changes.
215pub type PrismAvailabilityCallback =
216 Option<unsafe extern "C" fn(userdata: *mut c_void, backend: PrismBackendId, name: *const c_char, available: bool)>;
217
218/// The type of a function invoked once the poll thread has established its availability baseline.
219pub type PrismAvailabilityBaselineCallback = Option<unsafe extern "C" fn(userdata: *mut c_void)>;
220
221/// Receives audio samples from `prism_backend_speak_to_memory`.
222pub type PrismAudioCallback = Option<
223 unsafe extern "C" fn(
224 userdata: *mut c_void,
225 samples: *const f32,
226 sample_count: usize,
227 channels: usize,
228 sample_rate: usize,
229 ),
230>;
231
232/// The type of a function invoked to deliver a single log message.
233pub type PrismLogCallback = Option<
234 unsafe extern "C" fn(userdata: *mut c_void, level: PrismLogLevel, source: *const c_char, message: *const c_char),
235>;
236
237/// A struct containing configuration parameters for Prism or it's back-ends to use.
238#[repr(C)]
239#[derive(Debug, Clone, Copy)]
240pub struct PrismConfig {
241 /// The version of this structure. This field MUST NOT be modified.
242 pub version: u8,
243 /// The registry the created context will be bound to. This MAY be `NULL`, in which case the context uses the global registry. If non-null, it MUST be a registry obtained from `prism_registry_freeze`. This field was added in version 3 of this structure.
244 pub registry: *mut PrismRegistry,
245 /// A function invoked when a backend's runtime availability changes, or `NULL`. When this field is `NULL`, the context performs no background availability polling and creates no poll thread. When it is non-null, the context runs an internal thread that samples backend availability and invokes this callback on each confirmed transition. The behavior of this callback and the polling model are described in the chapter on background availability enumeration. This field was added in version 3 of this structure.
246 pub availability_callback: PrismAvailabilityCallback,
247 /// An opaque pointer passed unmodified to `availability_callback` on each invocation. Prism does not interpret or take ownership of this value. It is ignored when `availability_callback` is `NULL`. This field was added in version 3 of this structure.
248 pub availability_userdata: *mut c_void,
249 /// The base interval, in milliseconds, between availability scans. A value of `0` selects the default of 1000 milliseconds. It is ignored when `availability_callback` is `NULL`. This field was added in version 3 of this structure.
250 pub availability_poll_interval_ms: u32,
251 /// The number of consecutive agreeing samples required before a change in a backend's availability is confirmed and reported. A value of `0` selects the default of 2. A value of `1` confirms every observed change immediately, without debouncing. It is ignored when `availability_callback` is `NULL`. This field was added in version 3 of this structure.
252 pub availability_debounce_samples: u32,
253 /// The upper bound, in milliseconds, for adaptive backoff of the sampling interval. While availability is unchanging, the interval doubles from `availability_poll_interval_ms` toward this bound, and returns to the base interval as soon as any change is observed. A value of `0`, or any value not greater than the base interval, disables backoff and holds the interval constant. It is ignored when `availability_callback` is `NULL`. This field was added in version 3 of this structure.
254 pub availability_backoff_max_ms: u32,
255 /// When `true`, and when the library was built with power-management support, the poll thread is paused automatically when the operating system suspends and resumed when it wakes. When `false`, or on builds and platforms without power-management support, this field has no effect and the application MAY drive pausing itself. Use `prism_availability_auto_power_supported` to determine whether this field is honored. It is ignored when `availability_callback` is `NULL`. This field was added in version 3 of this structure.
256 pub availability_auto_power_manage: bool,
257 /// A function invoked exactly once per context, on the poll thread, after the first availability scan has completed and before the first invocation of `availability_callback`, or `NULL`. It receives `availability_userdata`. It is ignored when `availability_callback` is `NULL`. This field was added in version 4 of this structure.
258 pub availability_baseline_callback: PrismAvailabilityBaselineCallback,
259}
260
261/// A table of function pointers implementing a custom backend.
262#[repr(C)]
263#[derive(Debug, Clone, Copy)]
264pub struct PrismBackendVTable {
265 /// The size of this structure as known to the application. This member MUST be set to `sizeof(PrismBackendVTable)`. Prism reads at most `size` bytes from the structure. If `size` is smaller than the size of the structure as this version of Prism defines it, the members beyond `size` are treated as null; if it is larger, the additional bytes are ignored. This scheme permits the structure to grow in later library versions without invalidating applications compiled against earlier ones.
266 pub size: usize,
267 /// An optional function producing a per-instance state pointer. If non-null, Prism invokes it exactly once for each backend instance constructed from the registration, passing the registration's `userdata`, and thereafter passes the returned pointer as the `instance` argument to every other member invoked for that instance. Should `create` return `NULL`, construction of the instance fails. If `create` is null, the registration's `userdata` pointer is passed as the `instance` argument directly, and all instances of the backend consequently share it.
268 pub create: Option<unsafe extern "C" fn(userdata: *mut c_void) -> *mut c_void>,
269 /// An optional function releasing a state pointer previously returned by `create`. If both `create` and `destroy` are non-null, Prism invokes `destroy` exactly once for each backend instance, at the time the instance is freed. `destroy` is never invoked if `create` is null.
270 pub destroy: Option<unsafe extern "C" fn(instance: *mut c_void)>,
271 /// An optional runtime availability probe. If non-null, Prism invokes it to determine the `PRISM_BACKEND_IS_SUPPORTED_AT_RUNTIME` bit reported by `prism_backend_get_features`; if null, the bit declared at registration is reported unchanged. Because `prism_backend_get_features` MAY be called before initialization, `is_supported` MAY be invoked before `initialize` has succeeded, and an implementation of it MUST NOT assume the instance has been initialized. This member designates no operation and is therefore exempt from the feature consistency requirement of `prism_registry_builder_add_backend`.
272 pub is_supported: Option<unsafe extern "C" fn(instance: *mut c_void) -> bool>,
273 /// Implements `prism_backend_initialize`, taking the instance pointer in place of the backend. Null means the operation is unimplemented.
274 pub initialize: Option<unsafe extern "C" fn(instance: *mut c_void) -> PrismError>,
275 /// Implements `prism_backend_speak`, taking the instance pointer in place of the backend. Null means the operation is unimplemented.
276 pub speak: Option<unsafe extern "C" fn(instance: *mut c_void, text: *const c_char, interrupt: bool) -> PrismError>,
277 /// Implements `prism_backend_speak_to_memory`, taking the instance pointer in place of the backend. Null means the operation is unimplemented.
278 pub speak_to_memory: Option<
279 unsafe extern "C" fn(
280 instance: *mut c_void,
281 text: *const c_char,
282 callback: PrismAudioCallback,
283 callback_userdata: *mut c_void,
284 ) -> PrismError,
285 >,
286 /// Implements `prism_backend_braille`, taking the instance pointer in place of the backend. Null means the operation is unimplemented.
287 pub braille: Option<unsafe extern "C" fn(instance: *mut c_void, text: *const c_char) -> PrismError>,
288 /// Implements `prism_backend_output`, taking the instance pointer in place of the backend. Null means the operation is unimplemented.
289 pub output: Option<unsafe extern "C" fn(instance: *mut c_void, text: *const c_char, interrupt: bool) -> PrismError>,
290 /// Implements `prism_backend_stop`, taking the instance pointer in place of the backend. Null means the operation is unimplemented.
291 pub stop: Option<unsafe extern "C" fn(instance: *mut c_void) -> PrismError>,
292 /// Implements `prism_backend_pause`, taking the instance pointer in place of the backend. Null means the operation is unimplemented.
293 pub pause: Option<unsafe extern "C" fn(instance: *mut c_void) -> PrismError>,
294 /// Implements `prism_backend_resume`, taking the instance pointer in place of the backend. Null means the operation is unimplemented.
295 pub resume: Option<unsafe extern "C" fn(instance: *mut c_void) -> PrismError>,
296 /// Implements `prism_backend_is_speaking`, taking the instance pointer in place of the backend. Null means the operation is unimplemented.
297 pub is_speaking: Option<unsafe extern "C" fn(instance: *mut c_void, out_speaking: *mut bool) -> PrismError>,
298 /// Implements `prism_backend_set_volume`, taking the instance pointer in place of the backend. Null means the operation is unimplemented.
299 pub set_volume: Option<unsafe extern "C" fn(instance: *mut c_void, volume: f32) -> PrismError>,
300 /// Implements `prism_backend_get_volume`, taking the instance pointer in place of the backend. Null means the operation is unimplemented.
301 pub get_volume: Option<unsafe extern "C" fn(instance: *mut c_void, out_volume: *mut f32) -> PrismError>,
302 /// Implements `prism_backend_set_rate`, taking the instance pointer in place of the backend. Null means the operation is unimplemented.
303 pub set_rate: Option<unsafe extern "C" fn(instance: *mut c_void, rate: f32) -> PrismError>,
304 /// Implements `prism_backend_get_rate`, taking the instance pointer in place of the backend. Null means the operation is unimplemented.
305 pub get_rate: Option<unsafe extern "C" fn(instance: *mut c_void, out_rate: *mut f32) -> PrismError>,
306 /// Implements `prism_backend_set_pitch`, taking the instance pointer in place of the backend. Null means the operation is unimplemented.
307 pub set_pitch: Option<unsafe extern "C" fn(instance: *mut c_void, pitch: f32) -> PrismError>,
308 /// Implements `prism_backend_get_pitch`, taking the instance pointer in place of the backend. Null means the operation is unimplemented.
309 pub get_pitch: Option<unsafe extern "C" fn(instance: *mut c_void, out_pitch: *mut f32) -> PrismError>,
310 /// Implements `prism_backend_refresh_voices`, taking the instance pointer in place of the backend. Null means the operation is unimplemented.
311 pub refresh_voices: Option<unsafe extern "C" fn(instance: *mut c_void) -> PrismError>,
312 /// Implements `prism_backend_count_voices`, taking the instance pointer in place of the backend. Null means the operation is unimplemented.
313 pub count_voices: Option<unsafe extern "C" fn(instance: *mut c_void, out_count: *mut usize) -> PrismError>,
314 /// Implements `prism_backend_get_voice_name`, taking the instance pointer in place of the backend. Null means the operation is unimplemented.
315 pub get_voice_name: Option<
316 unsafe extern "C" fn(instance: *mut c_void, voice_id: usize, out_name: *mut *const c_char) -> PrismError,
317 >,
318 /// Implements `prism_backend_get_voice_language`, taking the instance pointer in place of the backend. Null means the operation is unimplemented.
319 pub get_voice_language: Option<
320 unsafe extern "C" fn(instance: *mut c_void, voice_id: usize, out_language: *mut *const c_char) -> PrismError,
321 >,
322 /// Implements `prism_backend_set_voice`, taking the instance pointer in place of the backend. Null means the operation is unimplemented.
323 pub set_voice: Option<unsafe extern "C" fn(instance: *mut c_void, voice_id: usize) -> PrismError>,
324 /// Implements `prism_backend_get_voice`, taking the instance pointer in place of the backend. Null means the operation is unimplemented.
325 pub get_voice: Option<unsafe extern "C" fn(instance: *mut c_void, out_voice_id: *mut usize) -> PrismError>,
326 /// Implements `prism_backend_get_channels`, taking the instance pointer in place of the backend. Null means the operation is unimplemented.
327 pub get_channels: Option<unsafe extern "C" fn(instance: *mut c_void, out_channels: *mut usize) -> PrismError>,
328 /// Implements `prism_backend_get_sample_rate`, taking the instance pointer in place of the backend. Null means the operation is unimplemented.
329 pub get_sample_rate: Option<unsafe extern "C" fn(instance: *mut c_void, out_sample_rate: *mut usize) -> PrismError>,
330 /// Implements `prism_backend_get_bit_depth`, taking the instance pointer in place of the backend. Null means the operation is unimplemented.
331 pub get_bit_depth: Option<unsafe extern "C" fn(instance: *mut c_void, out_bit_depth: *mut usize) -> PrismError>,
332}
333
334/// A structure pairing a log callback with an opaque user pointer.
335#[repr(C)]
336#[derive(Debug, Clone, Copy)]
337pub struct PrismLogHandler {
338 /// The callback invoked to deliver messages, or `NULL` to install no handler. When `fn` is `NULL`, messages are discarded.
339 pub fn_: PrismLogCallback,
340 /// An opaque pointer passed unmodified to `fn` on each invocation. Prism does not interpret or take ownership of this value. The lifetime of this value is the lifetime of the handler function, and therefore this value must be valid for as long as the handler is alive.
341 pub userdata: *mut c_void,
342}
343
344/// A structure through which a backend supplied by a plugin reaches the facilities Prism makes available to it. Prism provides one to each backend it registers from a plugin, as described under Host services.
345#[repr(C)]
346#[derive(Debug)]
347pub struct PrismPluginServices {
348 /// The size of this structure as Prism understands it. A backend MUST consult at most this many bytes and MUST treat any member beyond it as absent. A later generation MAY append members after those defined here.
349 pub struct_size: u32,
350 /// Reserved for future use. Prism sets this member to zero, and a backend MUST ignore it.
351 pub reserved: u32,
352 /// A function through which the backend records diagnostics. Its first argument MUST be the services object Prism supplied. Prism records the diagnostic under the name of the backend to which the services object belongs; the backend does not supply a source. This member is never `NULL`.
353 pub log: Option<unsafe extern "C" fn(self_: *const Self, level: PrismLogLevel, message: *const c_char)>,
354}
355
356/// The structure Prism passes as the `userdata` argument to the `create` member of a backend supplied by a plugin. The context is valid only for the duration of the `create` call; the services object it names is valid for the longer period given under Host services.
357#[repr(C)]
358#[derive(Debug)]
359pub struct PrismPluginInstanceContext {
360 /// The size of this structure as Prism understands it. A backend MUST consult at most this many bytes and MUST treat any member beyond it as absent.
361 pub struct_size: u32,
362 /// Reserved for future use. Prism sets this member to zero, and a backend MUST ignore it.
363 pub reserved: u32,
364 /// The backend's services object. A backend MAY retain it for the period given under Host services. This member is never `NULL`.
365 pub services: *const PrismPluginServices,
366 /// The value of the `userdata` member of the descriptor from which the backend was registered.
367 pub userdata: *mut c_void,
368}
369
370/// A structure describing the loading Prism library, passed to a plugin's entry point.
371#[repr(C)]
372#[derive(Debug)]
373pub struct PrismPluginHost {
374 /// The plugin ABI generation this implementation provides, equal to the `PRISM_PLUGIN_ABI_VERSION` against which Prism was compiled. A plugin MAY compare this value against its own requirements and decline to supply backends if it requires a newer host.
375 pub abi_version: u64,
376 /// The size of this structure as Prism understands it. A plugin MUST consult at most this many bytes and MUST treat any member beyond it as absent.
377 pub struct_size: u32,
378 /// Reserved for future use. Prism sets this member to zero, and a plugin MUST ignore it.
379 pub reserved: u32,
380 /// A function through which the plugin MAY record diagnostics during the entry point call. Its first argument MUST be the host descriptor Prism supplied; the plugin does not supply a source, and Prism records the diagnostic under a source that names the library being loaded. This member is never `NULL`. A plugin SHOULD use it to state the reason for declining a host, and MUST NOT retain the pointer beyond the entry point call.
381 pub log: Option<unsafe extern "C" fn(self_: *const Self, level: PrismLogLevel, message: *const c_char)>,
382}
383
384/// A descriptor supplied by a plugin to describe a single backend.
385#[repr(C)]
386#[derive(Debug)]
387pub struct PrismPluginBackend {
388 /// The plugin ABI generation this descriptor was built against. A plugin MUST set this member to the `PRISM_PLUGIN_ABI_VERSION` against which it was compiled. Prism rejects a descriptor whose generation it does not accept, as described under ABI compatibility.
389 pub abi_version: u64,
390 /// The size of this structure as the plugin understands it. A plugin MUST set this member to `sizeof(PrismPluginBackend)`. Prism consults at most this many bytes.
391 pub struct_size: u32,
392 /// Reserved for future use. A plugin MUST set this member to zero.
393 pub reserved: u32,
394 /// The backend's name, as a null-terminated UTF-8 string, subject to the same requirements and consequences as the `name` parameter of `prism_registry_builder_add_backend`. The backend's identifier is derived from it by the hash function described in the chapter on backend identifiers. The string is copied during loading.
395 pub name: *const c_char,
396 /// The backend's priority. Higher values indicate higher priority. This value MUST be non-negative unless the loading call supplies a priority override, in which case it is ignored.
397 pub priority: c_int,
398 /// The feature set the backend declares, formed by `ORing` `PRISM_BACKEND_*` feature constants together. It MUST be consistent with the vtable in the sense required of any custom backend.
399 pub features: u64,
400 /// The vtable implementing the backend, subject to every requirement placed on a vtable by the chapter on custom backends. This member MUST NOT be `NULL`, and its `size` member MUST be set as that chapter requires. The vtable MUST provide a `create` member, as described under Host services. The vtable is copied during loading; the code it names remains valid while the library remains loaded.
401 pub vtable: *const PrismBackendVTable,
402 /// An opaque pointer that Prism delivers to the backend's `create` member as the `userdata` member of a `PrismPluginInstanceContext` (see `PrismPluginInstanceContext`). It has the meaning the `userdata` parameter of `prism_registry_builder_add_backend` would have, and permits several descriptors that share one vtable to be distinguished at instance creation. This member MAY be `NULL`. Prism does not free it.
403 pub userdata: *mut c_void,
404 /// An informational version identifying the plugin's own release, distinct from the ABI generation and used for no compatibility decision. The value is three 16-bit components, major, minor, and patch, packed most-significant first, with the least-significant 16 bits reserved and set to zero. A plugin MAY set it to zero if it has no version to report.
405 pub plugin_version: u64,
406}
407
408/// The entry point a prism plugin shared library exports.
409pub type PrismPluginQueryFn =
410 Option<unsafe extern "C" fn(host: *const PrismPluginHost, index: usize) -> *const PrismPluginBackend>;
411
412unsafe extern "C" {
413 /// Creates a new configuration structure which can be passed to `prism_init`.
414 ///
415 /// # Safety
416 ///
417 /// Safe to call at any time; this is `unsafe` only because it crosses the FFI boundary.
418 pub fn prism_config_init() -> PrismConfig;
419 /// Creates a new Prism context.
420 ///
421 /// # Safety
422 ///
423 /// `cfg` must be null, or point to a writable, initialized `PrismConfig`.
424 pub fn prism_init(cfg: *mut PrismConfig) -> *mut PrismContext;
425 /// Destroys a Prism context and releases associated resources.
426 ///
427 /// # Safety
428 ///
429 /// `ctx` must be a live context from `prism_init` that has not been passed to `prism_shutdown`.
430 /// The context is invalid once this returns.
431 pub fn prism_shutdown(ctx: *mut PrismContext);
432 /// Pauses the availability poll thread.
433 ///
434 /// # Safety
435 ///
436 /// `ctx` must be a live context from `prism_init` that has not been passed to `prism_shutdown`.
437 pub fn prism_availability_poll_pause(ctx: *mut PrismContext);
438 /// Resumes the availability poll thread.
439 ///
440 /// # Safety
441 ///
442 /// `ctx` must be a live context from `prism_init` that has not been passed to `prism_shutdown`.
443 pub fn prism_availability_poll_resume(ctx: *mut PrismContext);
444 /// Reports whether this build can pause and resume polling automatically in response to operating-system power transitions.
445 ///
446 /// # Safety
447 ///
448 /// Safe to call at any time; this is `unsafe` only because it crosses the FFI boundary.
449 pub fn prism_availability_auto_power_supported() -> bool;
450 /// Returns the number of backends registered in the registry.
451 ///
452 /// # Safety
453 ///
454 /// `ctx` must be a live context from `prism_init` that has not been passed to `prism_shutdown`.
455 pub fn prism_registry_count(ctx: *mut PrismContext) -> usize;
456 /// Returns the backend ID at the specified index in the registry.
457 ///
458 /// # Safety
459 ///
460 /// `ctx` must be a live context from `prism_init` that has not been passed to `prism_shutdown`.
461 pub fn prism_registry_id_at(ctx: *mut PrismContext, index: usize) -> PrismBackendId;
462 /// Looks up a backend by name and returns its ID.
463 ///
464 /// # Safety
465 ///
466 /// `ctx` must be a live context from `prism_init` that has not been passed to `prism_shutdown`.
467 /// `name` must be a non-null, NUL-terminated UTF-8 string valid for the call.
468 pub fn prism_registry_id(ctx: *mut PrismContext, name: *const c_char) -> PrismBackendId;
469 /// Returns the human-readable name of a backend given its ID.
470 ///
471 /// # Safety
472 ///
473 /// `ctx` must be a live context from `prism_init` that has not been passed to `prism_shutdown`.
474 pub fn prism_registry_name(ctx: *mut PrismContext, id: PrismBackendId) -> *const c_char;
475 /// Returns the priority value of a backend.
476 ///
477 /// # Safety
478 ///
479 /// `ctx` must be a live context from `prism_init` that has not been passed to `prism_shutdown`.
480 pub fn prism_registry_priority(ctx: *mut PrismContext, id: PrismBackendId) -> c_int;
481 /// Checks whether a backend with the given ID exists in the registry.
482 ///
483 /// # Safety
484 ///
485 /// `ctx` must be a live context from `prism_init` that has not been passed to `prism_shutdown`.
486 pub fn prism_registry_exists(ctx: *mut PrismContext, id: PrismBackendId) -> bool;
487 /// Retrieves a cached backend instance if one exists.
488 ///
489 /// # Safety
490 ///
491 /// `ctx` must be a live context from `prism_init` that has not been passed to `prism_shutdown`.
492 pub fn prism_registry_get(ctx: *mut PrismContext, id: PrismBackendId) -> *mut PrismBackend;
493 /// Creates a new backend instance.
494 ///
495 /// # Safety
496 ///
497 /// `ctx` must be a live context from `prism_init` that has not been passed to `prism_shutdown`.
498 pub fn prism_registry_create(ctx: *mut PrismContext, id: PrismBackendId) -> *mut PrismBackend;
499 /// Creates a new instance of the highest-priority backend that successfully initializes.
500 ///
501 /// # Safety
502 ///
503 /// `ctx` must be a live context from `prism_init` that has not been passed to `prism_shutdown`.
504 pub fn prism_registry_create_best(ctx: *mut PrismContext) -> *mut PrismBackend;
505 /// Acquires a backend instance, reusing a cached instance if available or creating a new one otherwise.
506 ///
507 /// # Safety
508 ///
509 /// `ctx` must be a live context from `prism_init` that has not been passed to `prism_shutdown`.
510 pub fn prism_registry_acquire(ctx: *mut PrismContext, id: PrismBackendId) -> *mut PrismBackend;
511 /// Acquires the highest-priority backend that successfully initializes, reusing a cached instance if available.
512 ///
513 /// # Safety
514 ///
515 /// `ctx` must be a live context from `prism_init` that has not been passed to `prism_shutdown`.
516 pub fn prism_registry_acquire_best(ctx: *mut PrismContext) -> *mut PrismBackend;
517 /// Releases a backend instance.
518 ///
519 /// # Safety
520 ///
521 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
522 /// The pointer is invalid once this returns.
523 pub fn prism_backend_free(backend: *mut PrismBackend);
524 /// Returns the human-readable name of a backend.
525 ///
526 /// # Safety
527 ///
528 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
529 pub fn prism_backend_name(backend: *mut PrismBackend) -> *const c_char;
530 /// Returns a bitmask of all features supported by this backend, as well as other information.
531 ///
532 /// # Safety
533 ///
534 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
535 pub fn prism_backend_get_features(backend: *mut PrismBackend) -> u64;
536 /// Initializes a backend instance.
537 ///
538 /// # Safety
539 ///
540 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
541 pub fn prism_backend_initialize(backend: *mut PrismBackend) -> PrismError;
542 /// Synthesizes speech from the given text and plays it through the default audio output.
543 ///
544 /// # Safety
545 ///
546 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
547 /// `text` must be a non-null, NUL-terminated UTF-8 string valid for the call.
548 pub fn prism_backend_speak(backend: *mut PrismBackend, text: *const c_char, interrupt: bool) -> PrismError;
549 /// Synthesizes speech from the given text and delivers the audio samples to a callback function.
550 ///
551 /// # Safety
552 ///
553 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
554 /// `text` must be a non-null, NUL-terminated UTF-8 string valid for the call.
555 /// `userdata` is passed through untouched; it must satisfy whatever the paired callback expects and stay alive as long as that callback can run.
556 pub fn prism_backend_speak_to_memory(
557 backend: *mut PrismBackend,
558 text: *const c_char,
559 callback: PrismAudioCallback,
560 userdata: *mut c_void,
561 ) -> PrismError;
562 /// Outputs text to a connected braille display.
563 ///
564 /// # Safety
565 ///
566 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
567 /// `text` must be a non-null, NUL-terminated UTF-8 string valid for the call.
568 pub fn prism_backend_braille(backend: *mut PrismBackend, text: *const c_char) -> PrismError;
569 /// Outputs text using all available modalities supported by the backend.
570 ///
571 /// # Safety
572 ///
573 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
574 /// `text` must be a non-null, NUL-terminated UTF-8 string valid for the call.
575 pub fn prism_backend_output(backend: *mut PrismBackend, text: *const c_char, interrupt: bool) -> PrismError;
576 /// Immediately stops any currently playing speech.
577 ///
578 /// # Safety
579 ///
580 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
581 pub fn prism_backend_stop(backend: *mut PrismBackend) -> PrismError;
582 /// Pauses currently playing speech.
583 ///
584 /// # Safety
585 ///
586 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
587 pub fn prism_backend_pause(backend: *mut PrismBackend) -> PrismError;
588 /// Resumes previously paused speech.
589 ///
590 /// # Safety
591 ///
592 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
593 pub fn prism_backend_resume(backend: *mut PrismBackend) -> PrismError;
594 /// Queries whether the backend is currently producing speech output.
595 ///
596 /// # Safety
597 ///
598 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
599 /// `out_speaking` must be null, or a writable pointer to a `bool`.
600 pub fn prism_backend_is_speaking(backend: *mut PrismBackend, out_speaking: *mut bool) -> PrismError;
601 /// Sets the speech volume.
602 ///
603 /// # Safety
604 ///
605 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
606 pub fn prism_backend_set_volume(backend: *mut PrismBackend, volume: f32) -> PrismError;
607 /// Retrieves the current speech volume.
608 ///
609 /// # Safety
610 ///
611 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
612 /// `out_volume` must be null, or a writable pointer to a `f32`.
613 pub fn prism_backend_get_volume(backend: *mut PrismBackend, out_volume: *mut f32) -> PrismError;
614 /// Sets the speech rate (speed).
615 ///
616 /// # Safety
617 ///
618 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
619 pub fn prism_backend_set_rate(backend: *mut PrismBackend, rate: f32) -> PrismError;
620 /// Retrieves the current speech rate.
621 ///
622 /// # Safety
623 ///
624 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
625 /// `out_rate` must be null, or a writable pointer to a `f32`.
626 pub fn prism_backend_get_rate(backend: *mut PrismBackend, out_rate: *mut f32) -> PrismError;
627 /// Sets the speech pitch.
628 ///
629 /// # Safety
630 ///
631 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
632 pub fn prism_backend_set_pitch(backend: *mut PrismBackend, pitch: f32) -> PrismError;
633 /// Retrieves the current speech pitch.
634 ///
635 /// # Safety
636 ///
637 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
638 /// `out_pitch` must be null, or a writable pointer to a `f32`.
639 pub fn prism_backend_get_pitch(backend: *mut PrismBackend, out_pitch: *mut f32) -> PrismError;
640 /// Refreshes the backend's internal voice list.
641 ///
642 /// # Safety
643 ///
644 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
645 pub fn prism_backend_refresh_voices(backend: *mut PrismBackend) -> PrismError;
646 /// Returns the number of voices available from the backend.
647 ///
648 /// # Safety
649 ///
650 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
651 /// `out_count` must be null, or a writable pointer to a `usize`.
652 pub fn prism_backend_count_voices(backend: *mut PrismBackend, out_count: *mut usize) -> PrismError;
653 /// Retrieves the human-readable name of a voice.
654 ///
655 /// # Safety
656 ///
657 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
658 /// `out_name` must be null, or a writable pointer to a `*const c_char`.
659 pub fn prism_backend_get_voice_name(
660 backend: *mut PrismBackend,
661 voice_id: usize,
662 out_name: *mut *const c_char,
663 ) -> PrismError;
664 /// Retrieves the language code or language string of a voice.
665 ///
666 /// # Safety
667 ///
668 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
669 /// `out_language` must be null, or a writable pointer to a `*const c_char`.
670 pub fn prism_backend_get_voice_language(
671 backend: *mut PrismBackend,
672 voice_id: usize,
673 out_language: *mut *const c_char,
674 ) -> PrismError;
675 /// Selects a voice to use for subsequent speech synthesis.
676 ///
677 /// # Safety
678 ///
679 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
680 pub fn prism_backend_set_voice(backend: *mut PrismBackend, voice_id: usize) -> PrismError;
681 /// Retrieves the index of the currently selected voice.
682 ///
683 /// # Safety
684 ///
685 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
686 /// `out_voice_id` must be null, or a writable pointer to a `usize`.
687 pub fn prism_backend_get_voice(backend: *mut PrismBackend, out_voice_id: *mut usize) -> PrismError;
688 /// Retrieves the number of audio channels produced by the backend.
689 ///
690 /// # Safety
691 ///
692 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
693 /// `out_channels` must be null, or a writable pointer to a `usize`.
694 pub fn prism_backend_get_channels(backend: *mut PrismBackend, out_channels: *mut usize) -> PrismError;
695 /// Retrieves the sample rate of audio produced by the backend.
696 ///
697 /// # Safety
698 ///
699 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
700 /// `out_sample_rate` must be null, or a writable pointer to a `usize`.
701 pub fn prism_backend_get_sample_rate(backend: *mut PrismBackend, out_sample_rate: *mut usize) -> PrismError;
702 /// Retrieves the native bit depth of audio produced by the backend.
703 ///
704 /// # Safety
705 ///
706 /// `backend` must be a live backend that has not been passed to `prism_backend_free`.
707 /// `out_bit_depth` must be null, or a writable pointer to a `usize`.
708 pub fn prism_backend_get_bit_depth(backend: *mut PrismBackend, out_bit_depth: *mut usize) -> PrismError;
709 /// Returns a human-readable description of an error code.
710 ///
711 /// # Safety
712 ///
713 /// Safe to call at any time; this is `unsafe` only because it crosses the FFI boundary.
714 pub fn prism_error_string(error: PrismError) -> *const c_char;
715 /// Creates a new registry builder seeded with the compiled-in backends.
716 ///
717 /// # Safety
718 ///
719 /// Safe to call at any time; this is `unsafe` only because it crosses the FFI boundary.
720 pub fn prism_registry_builder_new() -> *mut PrismRegistryBuilder;
721 /// Adds a custom backend to a registry builder.
722 ///
723 /// # Safety
724 ///
725 /// `builder` must be a live builder that has not been freed.
726 /// `vtable` must point to an initialized `PrismBackendVTable` whose `size` member is set, valid for the call.
727 /// `name` must be a non-null, NUL-terminated UTF-8 string valid for the call.
728 /// `out_id` must be null, or a writable pointer to a `PrismBackendId`.
729 /// `userdata` is passed through untouched; it must satisfy whatever the paired callback expects and stay alive as long as that callback can run.
730 pub fn prism_registry_builder_add_backend(
731 builder: *mut PrismRegistryBuilder,
732 name: *const c_char,
733 priority: c_int,
734 features: u64,
735 vtable: *const PrismBackendVTable,
736 userdata: *mut c_void,
737 userdata_free: Option<unsafe extern "C" fn(*mut c_void)>,
738 out_id: *mut PrismBackendId,
739 ) -> PrismError;
740 /// Loads a plugin from a shared library and adds each backend it supplies to a registry builder.
741 ///
742 /// # Safety
743 ///
744 /// `builder` must be a live builder that has not been freed.
745 /// `path` must be a non-null, NUL-terminated UTF-8 string valid for the call.
746 /// `out_count` must be null, or a writable pointer to a `usize`.
747 pub fn prism_registry_builder_add_library(
748 builder: *mut PrismRegistryBuilder,
749 path: *const c_char,
750 priority_override: c_int,
751 out_count: *mut usize,
752 ) -> PrismError;
753 /// Freezes a builder, producing an immutable registry.
754 ///
755 /// # Safety
756 ///
757 /// `builder` must be a live builder that has not been freed.
758 pub fn prism_registry_freeze(builder: *mut PrismRegistryBuilder) -> *mut PrismRegistry;
759 /// Releases a registry builder.
760 ///
761 /// # Safety
762 ///
763 /// `builder` must be a live builder that has not been freed.
764 /// The builder is invalid once this returns.
765 pub fn prism_registry_builder_free(builder: *mut PrismRegistryBuilder);
766 /// Increments the reference count of a registry.
767 ///
768 /// # Safety
769 ///
770 /// `registry` must be null, or a live registry the caller holds a reference to.
771 pub fn prism_registry_retain(registry: *mut PrismRegistry) -> *mut PrismRegistry;
772 /// Decrements the reference count of a registry, finalizing it when the count reaches zero.
773 ///
774 /// # Safety
775 ///
776 /// `registry` must be null, or a live registry the caller holds a reference to.
777 /// The caller must not release more references than it holds.
778 pub fn prism_registry_release(registry: *mut PrismRegistry);
779 /// Installs the handler that receives log messages, replacing any previously installed handler.
780 ///
781 /// # Safety
782 ///
783 /// `handler.fn_`, if set, must be safe to call with `handler.userdata` from prism's logging thread, and that userdata must outlive the handler.
784 pub fn prism_set_log_handler(handler: PrismLogHandler) -> PrismLogHandler;
785 /// Sets the minimum severity of messages that will be delivered.
786 ///
787 /// # Safety
788 ///
789 /// Safe to call at any time; this is `unsafe` only because it crosses the FFI boundary.
790 pub fn prism_set_log_level(level: PrismLogLevel) -> PrismLogLevel;
791 /// Emits a log message.
792 ///
793 /// # Safety
794 ///
795 /// `source` must be a non-null, NUL-terminated UTF-8 string valid for the call.
796 /// `message` must be a non-null, NUL-terminated UTF-8 string valid for the call.
797 pub fn prism_log(level: PrismLogLevel, source: *const c_char, message: *const c_char);
798 /// Blocks until all messages queued before the call have been delivered.
799 ///
800 /// # Safety
801 ///
802 /// Safe to call at any time; this is `unsafe` only because it crosses the FFI boundary.
803 pub fn prism_log_flush();
804 /// Stops the logging thread and releases the resources associated with the logger.
805 ///
806 /// # Safety
807 ///
808 /// Safe to call at any time; this is `unsafe` only because it crosses the FFI boundary.
809 pub fn prism_log_shutdown();
810 /// Returns the version of the loaded Prism library as an encoded integer.
811 ///
812 /// # Safety
813 ///
814 /// Safe to call at any time; this is `unsafe` only because it crosses the FFI boundary.
815 pub fn prism_version() -> u32;
816 /// Returns the version of the loaded Prism library as a human-readable string.
817 ///
818 /// # Safety
819 ///
820 /// Safe to call at any time; this is `unsafe` only because it crosses the FFI boundary.
821 pub fn prism_version_string() -> *const c_char;
822}