pub struct FireblocksConfig {
pub api_key: String,
pub url: String,
pub secret_path: Option<PathBuf>,
pub secret: Option<String>,
pub display_config: DisplayConfig,
pub signer: Signer,
pub extra: HashMap<String, Value>,
pub debug: bool,
pub mainnet: bool,
}Fields§
§api_key: String§url: String§secret_path: Option<PathBuf>§secret: Option<String>§display_config: DisplayConfig§signer: Signer§extra: HashMap<String, Value>Arbitrary extra configuration values
debug: boolEnable debug mode
mainnet: boolImplementations§
Source§impl FireblocksConfig
impl FireblocksConfig
Sourcepub fn get_extra<T, K>(&self, key: K) -> Result<T>
pub fn get_extra<T, K>(&self, key: K) -> Result<T>
Get an extra configuration value as any deserializable type
Sourcepub fn get_extra_duration<K>(&self, key: K) -> Result<Duration>
pub fn get_extra_duration<K>(&self, key: K) -> Result<Duration>
Get an extra configuration value as a Duration from seconds
This function retrieves a numeric value from the extra configuration
and converts it to a std::time::Duration using
Duration::from_secs().
§Arguments
key- The configuration key to look up (can be&str,String, etc.)
§Returns
Ok(Duration)- The duration value if the key exists and can be parsed as u64Err(Error::NotPresent)- If the key doesn’t exist in the configurationErr(Error::ConfigParseError)- If the value cannot be deserialized as u64
§Examples
use {fireblocks_config::FireblocksConfig, std::time::Duration};
let config = FireblocksConfig::new("config.toml", &[])?;
// Get timeout as Duration (assuming config has: timeout = 30)
let timeout: Duration = config.get_extra_duration("timeout")?;
assert_eq!(timeout, Duration::from_secs(30));pub fn get_key(&self) -> Result<Vec<u8>>
Source§impl FireblocksConfig
impl FireblocksConfig
pub fn new<P: AsRef<Path>>(cfg: P, cfg_overrides: &[P]) -> Result<Self>
pub fn with_overrides<P: AsRef<Path>>( cfg: P, overrides: impl IntoIterator<Item = P>, ) -> Result<Self>
Sourcepub fn init() -> Result<Self>
pub fn init() -> Result<Self>
Load configuration from XDG config directory (~/.config/fireblocks/default.toml)
Sourcepub fn init_with_profiles<S: AsRef<str>>(profiles: &[S]) -> Result<Self>
pub fn init_with_profiles<S: AsRef<str>>(profiles: &[S]) -> Result<Self>
Load configuration from XDG config directory with additional profile overrides
Loads ~/.config/fireblocks/default.toml as base config, then applies each profile from ~/.config/fireblocks/{profile}.toml in order.
§Example
use fireblocks_config::FireblocksConfig;
// Load default config only
let config = FireblocksConfig::init()?;
// Load default + production profile
let config = FireblocksConfig::init_with_profiles(&["production"])?;
// Load default + staging + production (layered)
let config = FireblocksConfig::init_with_profiles(&["staging", "production"])?;Trait Implementations§
Source§impl Clone for FireblocksConfig
impl Clone for FireblocksConfig
Source§fn clone(&self) -> FireblocksConfig
fn clone(&self) -> FireblocksConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FireblocksConfig
impl Debug for FireblocksConfig
Source§impl Default for FireblocksConfig
impl Default for FireblocksConfig
Source§fn default() -> FireblocksConfig
fn default() -> FireblocksConfig
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for FireblocksConfig
impl<'de> Deserialize<'de> for FireblocksConfig
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
Auto Trait Implementations§
impl Freeze for FireblocksConfig
impl RefUnwindSafe for FireblocksConfig
impl Send for FireblocksConfig
impl Sync for FireblocksConfig
impl Unpin for FireblocksConfig
impl UnwindSafe for FireblocksConfig
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