[][src]Struct preftool::ConfigKey

pub struct ConfigKey(_);

Represents a configuration key. Configuration keys are case-insensitive, and all instances are lower-cased.

Methods

impl ConfigKey[src]

pub fn empty() -> Self[src]

Get an empty config key.

pub fn is_empty(&self) -> bool[src]

pub fn len(&self) -> usize[src]

Key length.

pub fn separator() -> &'static str[src]

Configuration key seperator.

pub fn section_key(&self) -> Self[src]

Get the section key given a config path.

Arguments

  • path - configuration path.

Example

use preftool::ConfigKey;
assert_eq!(ConfigKey::from("").section_key(), "");
assert_eq!(ConfigKey::from("foo").section_key(), "foo");
assert_eq!(ConfigKey::from("foo:bar").section_key(), "bar");
assert_eq!(ConfigKey::from("foo:bar:baz").section_key(), "baz");

pub fn parent(&self) -> Self[src]

Get the parent config path.

Arguments

  • path - configuration path.

Example

use preftool::ConfigKey;
assert_eq!(ConfigKey::from("").parent(), "");
assert_eq!(ConfigKey::from("foo").parent(), "");
assert_eq!(ConfigKey::from("foo:bar").parent(), "foo");
assert_eq!(ConfigKey::from("foo:bar:baz").parent(), "foo:bar");

pub fn combine<S2: Into<ConfigKey>>(&self, key: S2) -> Self[src]

Combine two config path segments.

Arguments

  • path - configuration path.
  • key - configuration sub-key.

Example

use preftool::ConfigKey;
assert_eq!(ConfigKey::from("").combine(""), "");
assert_eq!(ConfigKey::from("").combine("foo"), "foo");
assert_eq!(ConfigKey::from("foo:bar").combine("baz"), "foo:bar:baz");
assert_eq!(ConfigKey::from("foo").combine("bar:baz"), "foo:bar:baz");

pub fn join<S: Into<ConfigKey>, I: IntoIterator<Item = S>>(parts: I) -> Self[src]

Join a list of path segments into one config path.

Arguments

  • paths - configuration path segments.

Example

use preftool::ConfigKey;
assert_eq!(ConfigKey::join::<&'static str, Vec<_>>(vec!()), "");
assert_eq!(ConfigKey::join(vec!("foo")), "foo");
assert_eq!(ConfigKey::join(vec!("", "foo", "")), "foo");
assert_eq!(ConfigKey::join(vec!("", "foo:bar", "", "baz")), "foo:bar:baz");

pub fn unsafe_from<S: Into<String>>(value: S) -> Self[src]

Construct a config key from a string. This does not do any validation/lowercasing of the string, and should only be used if the string is guaranteed to be safe. This method is typically used by derive implementations.

Arguments

  • value - string value.

Example

use preftool::ConfigKey;
assert_eq!(ConfigKey::unsafe_from("foo:bar"), "foo:bar");

Trait Implementations

impl AsRef<str> for ConfigKey[src]

impl Clone for ConfigKey[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<'_> From<&'_ str> for ConfigKey[src]

impl<'_> From<&'_ String> for ConfigKey[src]

impl From<String> for ConfigKey[src]

impl<'_> From<&'_ ConfigKey> for ConfigKey[src]

impl Eq for ConfigKey[src]

impl Into<String> for ConfigKey[src]

impl PartialEq<ConfigKey> for ConfigKey[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl PartialEq<String> for ConfigKey[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl PartialEq<str> for ConfigKey[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl<'_> PartialEq<&'_ String> for ConfigKey[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl<'_> PartialEq<&'_ str> for ConfigKey[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl Debug for ConfigKey[src]

impl Display for ConfigKey[src]

impl Hash for ConfigKey[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given [Hasher]. Read more

Auto Trait Implementations

impl Send for ConfigKey

impl Sync for ConfigKey

Blanket Implementations

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> SendSyncUnwindSafe for T where
    T: Send + Sync + UnwindSafe + ?Sized
[src]