wasmcloud_provider_sdk

Function parse_wit_meta_from_operation

source
pub fn parse_wit_meta_from_operation(
    operation: impl AsRef<str>,
) -> Result<(WitNamespace, WitPackage, WitInterface, Option<WitFunction>)>
Expand description

Parse an sufficiently specified WIT operation/method into constituent parts.

§Errors

Returns Err if the operation is not of the form “:/.

§Example

let (wit_ns, wit_pkg, wit_iface, wit_fn) = parse_wit_meta_from_operation(("wasmcloud:bus/guest-config"));
#assert_eq!(wit_ns, "wasmcloud")
#assert_eq!(wit_pkg, "bus")
#assert_eq!(wit_iface, "iface")
#assert_eq!(wit_fn, None)
let (wit_ns, wit_pkg, wit_iface, wit_fn) = parse_wit_meta_from_operation(("wasmcloud:bus/guest-config.get"));
#assert_eq!(wit_ns, "wasmcloud")
#assert_eq!(wit_pkg, "bus")
#assert_eq!(wit_iface, "iface")
#assert_eq!(wit_fn, Some("get"))