[−][src]Struct mininip::datas::Identifier
The identifier of a variable, which is its identity. Of course, this type is Hash
because it may be used as a key in a HashMap
Methods
impl Identifier
[src]
pub fn new(section: Option<String>, name: String) -> Identifier
[src]
Creates an identifier with a valid section name and a valid name
Panics
Panics if either section
or name
is an invalid identifier according to Identifier::is_valid
pub fn is_valid(ident: &str) -> bool
[src]
Returns true
if the given string is a valid identifier and false
otherwise
A valid identifier is defined as a string of latin alphanumeric characters and any of _
, ~
, -
, .
, :
, $
and space starting with a latin alphabetic one or any of .
, $
or :
. All of these characters must be ASCII
Notes
Since the INI file format is not really normalized, this definition may evolve in the future. In fact, I will avoid when possible to make a stronger rule, in order to keep backward compatibility
Examples
use mininip::datas::Identifier; assert!(Identifier::is_valid("identifier")); assert!(Identifier::is_valid("digits1230")); assert!(Identifier::is_valid("UPPERCASE_AND_UNDERSCORES")); assert!(Identifier::is_valid("contains spaces inside")); assert!(!Identifier::is_valid("123_starts_with_a_digit")); assert!(!Identifier::is_valid("invalid_characters;!\\~")); assert!(!Identifier::is_valid("é_is_unicode")); assert!(!Identifier::is_valid(" starts_with_a_space"));
pub fn name(&self) -> &str
[src]
Returns the name of the variable as a reference
pub fn section(&self) -> Option<&str>
[src]
Returns the section of the variable which may be a named section as Some(name)
or the "global scope" wich is None
pub fn change_name(&mut self, name: String)
[src]
pub fn change_section(&mut self, section: Option<String>)
[src]
Changes the section of the variable. section
may be Some(name)
with name
as the name of the section of None
for the "global scope"
Panics
Panics if section
is invalid according to Identifier::is_valid
Trait Implementations
impl Clone for Identifier
[src]
fn clone(&self) -> Identifier
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for Identifier
[src]
impl Display for Identifier
[src]
impl Eq for Identifier
[src]
impl Hash for Identifier
[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<Identifier> for Identifier
[src]
fn eq(&self, other: &Identifier) -> bool
[src]
fn ne(&self, other: &Identifier) -> bool
[src]
impl StructuralEq for Identifier
[src]
impl StructuralPartialEq for Identifier
[src]
Auto Trait Implementations
impl RefUnwindSafe for Identifier
impl Send for Identifier
impl Sync for Identifier
impl Unpin for Identifier
impl UnwindSafe for Identifier
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> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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>,