Skip to main content

hara_native/lang/protocol/
inamespaced.rs

1use hara_protocol_macros::hara_protocol;
2
3#[hara_protocol(namespace = "std.protocol.inamespaced", name = "INamespaced")]
4pub trait INamespaced {
5    #[hara_method(value = "name", arity = 1)]
6    fn get_name(&self) -> &str;
7    #[hara_method(value = "namespace", arity = 1)]
8    fn get_namespace(&self) -> Option<&str>;
9
10    fn path_string(&self) -> String {
11        match self.get_namespace() {
12            Some(namespace) => format!("{namespace}/{}", self.get_name()),
13            None => self.get_name().to_owned(),
14        }
15    }
16}