[−][src]Struct rna::Namespace
Namespace consist of 'prefix' and 'suffix'.
where 'prefix' is any string before :
and 'suffix' is any string after that
Example Namespaces
minecraft:test
-> prefix:minecraft
, suffix:test
megumin:explosion
-> prefix:megumin
, suffix:explosion
boomber:hello_world
-> prefix:boomber
, suffix:hello_world
Examples
Creating Namespace
This method will create new namespace without any check for invalid character in namespace.
let namespace = Namespace::new("megumin", "explosion"); assert_eq!(namespace.prefix, "megumin"); assert_eq!(namespace.suffix, "explosion");
Decode Namespace
This method will create new namespace while also check of any invalid syntax in namespace and will return DecodeError
if that happened.
let namespace = Namespace::decode("megumin:explosion").unwrap(); assert_eq!(namespace.prefix, "megumin"); assert_eq!(namespace.suffix, "explosion");
Fields
prefix: String
String that come before :
suffix: String
String that come after :
Methods
impl Namespace
[src]
pub fn new(prefix: impl Into<String>, suffix: impl Into<String>) -> Namespace
[src]
Manually create new Namespace
pub fn decode(value: impl Into<String>) -> Result<Namespace, DecodeError>
[src]
Create Namespace from a given string.
Errors
This method can error when:
- Input contain invalid characters for namespace
- Input contain too many colons (
:
) - There's an error inside
regex
crate
Examples
assert_eq!( Namespace::decode("boomber:hello_world").unwrap(), Namespace::new("boomber", "hello_world") );
If no colon is provided, 'minecraft' prefix will be used.
assert_eq!( Namespace::decode("without_prefix").unwrap(), Namespace::new("minecraft", "without_prefix") );
Trait Implementations
impl Clone for Namespace
[src]
impl Debug for Namespace
[src]
impl Eq for Namespace
[src]
impl<'_> From<&'_ str> for Namespace
[src]
Create Namespace from &str.
This will unwrap()
error emit from Namespace::decode()
function.
impl Hash for Namespace
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<Namespace> for Namespace
[src]
impl StructuralEq for Namespace
[src]
impl StructuralPartialEq for Namespace
[src]
Auto Trait Implementations
impl RefUnwindSafe for Namespace
impl Send for Namespace
impl Sync for Namespace
impl Unpin for Namespace
impl UnwindSafe for Namespace
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,