key
Module[Key]: the name a limit counts under, a pattern with placeholders.
Contents
use utopia_abuse::Key;Rust
pub struct KeyThe name a limit counts under: a pattern such as "ip:{ip}" whose
placeholders are replaced by parameters.
Rust
use utopia_abuse::Key;
let key = Key::new("{ip}:{url}").with_param("{ip}", "127.0.0.1").with_param("{url}", "/v1/account");
assert_eq!(key.as_str(), "127.0.0.1:/v1/account");
// A placeholder without a parameter stays literal.
assert_eq!(Key::new("{ip}:{url}").with_param("{ip}", "10.0.0.1").as_str(), "10.0.0.1:{url}");Also implements
Display.