Function wasmcloud_core::wit::parse_wit_package_name
source · pub fn parse_wit_package_name(
p: impl AsRef<str>,
) -> Result<(WitNamespace, Vec<WitPackage>, Option<Vec<WitInterface>>, Option<WitFunction>, Option<Version>)>
Expand description
Parse a WIT package name into constituent parts.
This function is parse_wit_meta_from_operation
but differs
in that it allows more portions to be missing, and handles more use cases,
like operations on resources
This formulation should also support future nested package/interface features in the WIT spec.
§Errors
Returns Err
if the operation is not of the form “<package>:<ns>/<interface>.<function>”
§Example
let (ns, packages, interfaces, func, version) = parse_wit_package_name("wasi:http").unwrap();
let (ns, packages, interfaces, func, version) = parse_wit_package_name("wasi:http@0.2.2").unwrap();
let (ns, packages, interfaces, func, version) = parse_wit_package_name("wasmcloud:bus/guest-config").unwrap();
let (ns, packages, interfaces, func, version) = parse_wit_package_name("wasmcloud:bus/guest-config.get").unwrap();
let (ns, packages, interfaces, func, version) = parse_wit_package_name("wasi:http/incoming-handler@0.2.0").unwrap();
let (ns, packages, interfaces, func, version) = parse_wit_package_name("wasi:keyvalue/atomics.increment@0.2.0-draft").unwrap();