v0.2.11-pre.002-fix.001
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
// file: crates/ksp-offchain-transport-lib/src/market_price_settings.rs
|
||||
// version: 2
|
||||
|
||||
/// Common provider settings embedded by future provider-specific runtime settings.
|
||||
///
|
||||
/// Provider-specific credentials, pair selectors and access modes intentionally do not live here because providers without those capabilities must not be
|
||||
/// forced into artificial fields.
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize)]
|
||||
pub struct PriceProviderCommonSettings {
|
||||
enabled: bool,
|
||||
provider_id: crate::PriceProviderId,
|
||||
}
|
||||
|
||||
impl PriceProviderCommonSettings {
|
||||
/// Creates common settings for one uniquely identified runtime provider instance.
|
||||
#[must_use]
|
||||
pub fn new(provider_id: crate::PriceProviderId, enabled: bool) -> Self {
|
||||
ksp_logging_lib::trace!(target: crate::TRACING_TARGET, enabled = enabled, "constructed common market-price provider settings");
|
||||
return Self { enabled, provider_id };
|
||||
}
|
||||
|
||||
/// Reports whether this provider instance is enabled.
|
||||
#[must_use]
|
||||
pub const fn enabled(&self) -> bool {
|
||||
return self.enabled;
|
||||
}
|
||||
|
||||
/// Returns the opaque runtime provider identifier.
|
||||
#[must_use]
|
||||
pub const fn provider_id(&self) -> &crate::PriceProviderId {
|
||||
return &self.provider_id;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "../unit_tests/market_price_settings.rs"]
|
||||
mod tests;
|
||||
Reference in New Issue
Block a user