Struct Config

Source
pub struct Config {
    pub feedback_error_file: Option<String>,
    pub feedback_info_file: Option<String>,
    pub file_not_found_file: String,
    pub filesystem_directory_index: String,
    pub filesystem_root: String,
    pub server_limit: usize,
    pub server_host: String,
    pub server_port: u32,
    pub tcp_limit: usize,
}
Expand description

§Holds application configuration, can be created in different ways.

§From environment:

use milstian_internet_framework::Config;
let config = Config::from_env();
assert!(config.is_err()); // Expected fail since environment variables is missing

Fields§

§feedback_error_file: Option<String>§feedback_info_file: Option<String>§file_not_found_file: String§filesystem_directory_index: String§filesystem_root: String§server_limit: usize§server_host: String§server_port: u32§tcp_limit: usize

Implementations§

Source§

impl Config

Source

pub fn get_canonical_root(root_path: &String) -> Result<String, String>

Find canonical root from a string path

Source

pub fn from_env_args(args: Vec<String>) -> Result<Config, String>

This method takes a vector of strings and creates a config struct based on argument vector

Source

pub fn from_env() -> Result<Config, String>

This method collects arguments from environment and passes them on to method from_env_args

§Example
use milstian_internet_framework::Config;
let config = Config::from_env();
assert!(config.is_err()); // Expected fail since environment variables is missing
Examples found in repository?
examples/static.rs (line 4)
3fn main() {
4    let config = Config::from_env().expect("Failed to get configuration from environment");
5    Application::new(config).tcp_http_with_legacy_responders();
6}
More examples
Hide additional examples
examples/dynamic.rs (line 102)
101fn main() {
102    let config = Config::from_env().expect("Failed to get configuration from environment");
103    Application::new(config).tcp_http_with_legacy_and_custom_responders(Box::new(Responder::new()));
104}

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.