Skip to main content

limits_from_toml_str

Function limits_from_toml_str 

pub fn limits_from_toml_str(raw: &str) -> Result<BrokerLimits, ConfigError>
Expand description

Reads the [bcs] section of a limits file given as text.

Other sections of the file (other brokers) are ignored. Give every connector of one BCS account the same BrokerLimiter built from the result, because the limits belong to the token.

§Errors

[brokapi_core::ConfigError::Message] when the text is not valid TOML, when there is no [bcs] section, or when the section is not a valid set of limits (see [BrokerLimits::from_toml_section]).

§Examples

use brokapi_bcs::limits::{limits_from_toml_str, DEFAULT_LIMITS_TOML};

assert!(limits_from_toml_str(DEFAULT_LIMITS_TOML).is_ok());
// A file for another broker has no [bcs] section.
assert!(limits_from_toml_str("[tbank.buckets.global]\nrate = 1").is_err());