Skip to main content

ForwardLimits

Struct ForwardLimits 

Source
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: TokenBucket

Join requests forwarded.

§notify: TokenBucket

Notifications of end devices the relay does not trust.

§global_uplink: TokenBucket

Uplinks forwarded for every trusted end device together.

§overall: TokenBucket

Everything the relay sends on behalf of others.

Implementations§

Source§

impl ForwardLimits

Source

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.

Source

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.
Source

pub fn reload(&mut self, hours: u64)

Adds what every bucket earns over some hours.

§Arguments
  • hours - the whole hours since the last reload.
Source

pub fn restart(&mut self)

Sets every bucket to one hour’s reload, as TS011-1.0.1 section 8.8 has a relay do when it starts scanning.

Trait Implementations§

Source§

impl Clone for ForwardLimits

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Copy for ForwardLimits

Source§

impl Debug for ForwardLimits

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ForwardLimits

Source§

fn default() -> ForwardLimits

Returns the “default value” for a type. Read more
Source§

impl Eq for ForwardLimits

Source§

impl Hash for ForwardLimits

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ForwardLimits

Source§

fn eq(&self, other: &ForwardLimits) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ForwardLimits

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.