pub struct ForwardLimits {
pub join_request: TokenBucket,
pub notify: TokenBucket,
pub global_uplink: TokenBucket,
pub overall: TokenBucket,
}Expand description
A relay’s four relay-wide limits, TS011-1.0.1 tables 23 and 24.
A join request spends a token of join_request and overall, an uplink from a trusted
end device one of its own bucket, global_uplink and overall, and a notification of an
unknown end device one of notify and overall.
§Examples
use pamoja_lorawan::relay::ForwardLimits;
let mut limits = ForwardLimits::new();
assert_eq!(limits.join_request.reload_rate(), Some(4));
assert_eq!(limits.join_request.size(), 8);
// A relay starts with an hour's worth of tokens, so a fifth join request waits.
for _ in 0..4 {
assert!(limits.join_request.take());
}
assert!(!limits.join_request.has_token());
// An hour on, four more arrive.
limits.reload(1);
assert_eq!(limits.join_request.tokens(), 4);Fields§
§join_request: TokenBucketJoin requests forwarded.
notify: TokenBucketNotifications of end devices the relay does not trust.
global_uplink: TokenBucketUplinks forwarded for every trusted end device together.
overall: TokenBucketEverything the relay sends on behalf of others.
Implementations§
Source§impl ForwardLimits
impl ForwardLimits
Sourcepub const fn new() -> ForwardLimits
pub const fn new() -> ForwardLimits
The limits of TS011-1.0.1 table 23, each holding one hour’s reload.
§Returns
Four join requests and four notifications an hour, each bucket twice that; and eight uplinks and eight messages overall an hour, each bucket sixteen.
Sourcepub fn configure(
&mut self,
reset: CounterReset,
reload_rates: [u8; 4],
bucket_sizes: [u8; 4],
)
pub fn configure( &mut self, reset: CounterReset, reload_rates: [u8; 4], bucket_sizes: [u8; 4], )
Takes a ConfigureFwdLimitReq, TS011-1.0.1 section 10.6.
§Arguments
reset- what happens to the counters.reload_rates- the coded rates, join request, notify, global uplink and overall, 127 meaning no limit.bucket_sizes- the coded size multipliers in the same order, table 55.
Trait Implementations§
Source§impl Clone for ForwardLimits
impl Clone for ForwardLimits
Source§fn clone(&self) -> ForwardLimits
fn clone(&self) -> ForwardLimits
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for ForwardLimits
Source§impl Debug for ForwardLimits
impl Debug for ForwardLimits
Source§impl Default for ForwardLimits
impl Default for ForwardLimits
Source§fn default() -> ForwardLimits
fn default() -> ForwardLimits
Returns the “default value” for a type. Read more
impl Eq for ForwardLimits
Source§impl Hash for ForwardLimits
impl Hash for ForwardLimits
Source§impl PartialEq for ForwardLimits
impl PartialEq for ForwardLimits
impl StructuralPartialEq for ForwardLimits
Auto Trait Implementations§
impl Freeze for ForwardLimits
impl RefUnwindSafe for ForwardLimits
impl Send for ForwardLimits
impl Sync for ForwardLimits
impl Unpin for ForwardLimits
impl UnsafeUnpin for ForwardLimits
impl UnwindSafe for ForwardLimits
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