Struct lockchain_http::state::ApiState [−][src]
pub struct ApiState<B, V> where
B: Body,
V: Vault<B>, { pub bound_scope: bool, pub working_dir: PathBuf, pub administrative: bool, // some fields omitted }
An in-memory API state object which is delegated to all handlers
This mechanism serves two purposes
- Configuration of the API, beyond simple paramters provided to the server_start call
- Buffering and pre-loading of certain vault components that need to be accessed via the handlers
It provides some simple query functions for handlers to work on, as well as expose raw configuration fields to be written
let state: ApiState<B, V> = ApiState { bound_scope: false, working_dir: ".".into(), .. };
(Replace B and V with your generics 🙂)
Fields
bound_scope: bool
Signal if the API handlers are allowed outside their working dir
working_dir: PathBuf
Provide a working directory
administrative: bool
Completely disabe administrative actions
Methods
impl<B, V> ApiState<B, V> where
B: Body,
V: Vault<B>, [src]
impl<B, V> ApiState<B, V> where
B: Body,
V: Vault<B>, pub fn load(encoded: &str) -> Option<Self>[src]
pub fn load(encoded: &str) -> Option<Self>Load an existing API state from an encoded string
pub fn store(&self) -> String[src]
pub fn store(&self) -> StringStore an in-memory API state to an encoded string
pub fn vaults(&self) -> Vec<&str>[src]
pub fn vaults(&self) -> Vec<&str>Return a list of string slices for each vault in scope
pub fn count(&self) -> usize[src]
pub fn count(&self) -> usizeSimply return the number of known vaults
pub fn add_vault(&mut self, name: &str, vault: V)[src]
pub fn add_vault(&mut self, name: &str, vault: V)pub fn get_vault(&mut self, name: &str) -> Option<&mut V>[src]
pub fn get_vault(&mut self, name: &str) -> Option<&mut V>