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 [bybit] section of a limits file given as text.

Other sections of the file (other brokers) are ignored.

§Errors

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

§Examples

use brokapi_bybit::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 [bybit] section.
assert!(limits_from_toml_str("[tbank.buckets.global]\nrate = 1").is_err());