pub struct Config {
pub listen: String,
pub storage_dir: Option<PathBuf>,
}Expand description
Server configuration, sourced from the process environment.
Fields§
§listen: Stringhost:port the HTTP server binds to (FERRO_OCI_LISTEN).
storage_dir: Option<PathBuf>Optional filesystem directory for blob bytes
(FERRO_OCI_STORAGE_DIR). When None, an in-memory blob store
is used — convenient for smoke tests and conformance runs, but
non-durable.
Implementations§
Source§impl Config
impl Config
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Read the configuration from the process environment, applying defaults for anything unset.
Sourcepub fn from_raw(listen: Option<String>, storage_dir: Option<PathBuf>) -> Self
pub fn from_raw(listen: Option<String>, storage_dir: Option<PathBuf>) -> Self
Build a Config from already-resolved listen / storage-dir
values, applying defaults for None.
Factored out of from_env so the parsing and
default rules are unit-testable without mutating the process
environment (which unsafe_code = forbid disallows here). An
empty storage_dir path is normalised to “in-memory”.
Sourcepub fn socket_addr(&self) -> Result<SocketAddr, String>
pub fn socket_addr(&self) -> Result<SocketAddr, String>
Parse and validate the listen address.
§Errors
Returns an error string when listen is not a valid
host:port socket address.
Sourcepub fn blob_store(&self) -> Result<SharedBlobStore, Box<dyn Error>>
pub fn blob_store(&self) -> Result<SharedBlobStore, Box<dyn Error>>
Build the SharedBlobStore this config describes.
§Errors
Returns an error when a filesystem store is requested but its directory cannot be created or opened.