1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! Shared helpers for the three Extism adapter modules.
//!
//! `acquire`, `extism_err_to_fn_err`, and the qname → export-symbol
//! sanitizer were copy-pasted across [`crate::adapter`],
//! [`crate::adapter_aggregate`], and [`crate::adapter_procedure`]. They
//! live here once so the lease/error/symbol conventions stay in lock-step
//! across the scalar, aggregate, and procedure adapters.
// Rust guideline compliant
use Arc;
use QName;
use FnError;
use IpcError;
use crate;
/// Sanitize a qname into the `.`-free stem used in plugin export symbols.
///
/// Plugin authors expose `invoke_<stem>` / `agg_<stem>_*` /
/// `proc_<stem>_invoke` where every `.` in the qname is replaced by `_`,
/// because Rust identifiers cannot contain `.`. The mapping is
/// deterministic and shared by all three adapters so the host always
/// derives the same export symbol from a canonical qname.
///
/// # Examples
///
/// ```
/// use uni_plugin::QName;
/// use uni_plugin_extism::adapter_common::sanitize_qname;
///
/// let q = QName::parse("geo.haversine").unwrap();
/// assert_eq!(sanitize_qname(&q), "geo_haversine");
/// ```
/// Lease one warm instance from `pool`, mapping pool exhaustion to a
/// [`FnError`] carrying [`FnError::CODE_RESOURCE_LIMIT`].
///
/// # Errors
///
/// Returns [`FnError`] when the pool cannot hand out an instance (e.g.
/// `max_instances` reached).
/// Map an Arrow-IPC boundary error to a [`FnError`] carrying
/// [`FnError::CODE_TYPE_COERCION`].