Skip to main content

CryptConfig

Struct CryptConfig 

Source
pub struct CryptConfig { /* private fields */ }
Expand description

A Crypt Configuration object

Uses a simple map for string identifiers to CryptObjects. Configs can contain other nested configs, string literals, and identifiers. String literals and identifiers are both stored as a String.

§Example

Example crypt file:

./tests/test.crypt

version = "0.1.0";
name = "Test";
type = "Executable"

Opening the file:

use crypt_configs::{open_config, body::CryptObject};
 
let config = match open_config("tests/test.crypt") {
    Ok(c) => c,
    Err(e) => panic!("Failed to open test file!"),
};
 
assert_eq!(config.get("version").unwrap().try_into(), Ok(&String::from("0.1.0")));
assert_eq!(config.get("name").unwrap().try_into(), Ok(&String::from("Test")));
assert_eq!(config.get("type").unwrap().try_into(), Ok(&String::from("Executable")));

Implementations§

Source§

impl CryptConfig

Source

pub fn get<S>(&self, ident: S) -> Option<&CryptObject>
where S: Into<String>,

Retrieves an item from the config

The object is ambiguously wrapped in a CryptObject.

Trait Implementations§

Source§

impl Debug for CryptConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for CryptConfig

Source§

impl PartialEq for CryptConfig

Source§

fn eq(&self, other: &CryptConfig) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for CryptConfig

Source§

impl<'a> TryInto<&'a CryptConfig> for &'a CryptObject

Source§

type Error = CryptConversionError

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<&'a CryptConfig, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.