pub struct Config {
pub server: ServerConfig,
pub cache: CacheConfig,
}
Expand description
Configuration structure for the server
Fields§
§server: ServerConfig
§cache: CacheConfig
Implementations§
Source§impl Config
impl Config
Sourcepub fn with_env(self) -> Result<Self>
pub fn with_env(self) -> Result<Self>
Create a new configuration, with it’s values updated from environment variables
This function reads environment variables prefixed with RANDOM_IMAGE_SERVER_
and updates the configuration accordingly. It supports the following variables:
RANDOM_IMAGE_SERVER_PORT
: The port for the serverRANDOM_IMAGE_SERVER_HOST
: The host for the serverRANDOM_IMAGE_SERVER_LOG_LEVEL
: The log level for the serverRANDOM_IMAGE_SERVER_SOURCES
: A comma-separated list of image sources (URLs or paths)RANDOM_IMAGE_SERVER_CACHE_BACKEND
: The cache backend type, eitherin_memory
orfile_system
§Errors
Returns an error if any environment variable is invalid or cannot be parsed.
Sourcepub fn with_env_backend(self, env: &impl EnvBackend) -> Result<Self>
pub fn with_env_backend(self, env: &impl EnvBackend) -> Result<Self>
Create a new configuration, with it’s values updated from environment variables.
Same as with_env
, but allows passing a custom environment backend (e.g., for testing).
§Errors
Returns an error if any environment variable is invalid or cannot be parsed.
Sourcepub fn socket_addr(&self) -> Result<SocketAddr, AddrParseError>
pub fn socket_addr(&self) -> Result<SocketAddr, AddrParseError>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Config
impl StructuralPartialEq for Config
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.