pub struct OwnedChannelPlan { /* private fields */ }Expand description
A channel plan that owns its tables.
Query it through with_plan, which lends the tables to a
borrowed ChannelPlan for the duration of one call.
Implementations§
Source§impl OwnedChannelPlan
impl OwnedChannelPlan
Sourcepub fn from_plan(plan: &ChannelPlan<'_>) -> Self
pub fn from_plan(plan: &ChannelPlan<'_>) -> Self
Copies a borrowed plan into owned storage.
This is how a host takes a published region and holds onto it: the result is independent of where the original tables lived, so one type serves both a named region and a plan built here.
The copy describes the one plan it was taken from. The plans a join selects between, which only the published CN470-510 plans name, point at other published plans and are not carried over.
§Arguments
plan- the plan to copy.
§Returns
An owned copy answering exactly what the original does.
§Examples
use pamoja_lora::region::{OwnedChannelPlan, Region};
let held = OwnedChannelPlan::from_plan(Region::Eu868.plan());
assert_eq!(held.with_plan(|plan| plan.rx2()), (869_525_000, 0));Sourcepub fn with_plan<R>(&self, query: impl FnOnce(&ChannelPlan<'_>) -> R) -> R
pub fn with_plan<R>(&self, query: impl FnOnce(&ChannelPlan<'_>) -> R) -> R
Lends the owned tables to a borrowed plan for one query.
The row pointers a plan needs are assembled on the stack for the call, so nothing outlives it and the storage stays here.
§Arguments
query- what to ask the plan.
§Returns
Whatever the query returned.
§Examples
use pamoja_lora::region::{OwnedChannelPlan, Region};
let held = OwnedChannelPlan::from_plan(Region::In865.plan());
let name = held.with_plan(|plan| plan.name.to_owned());
assert_eq!(name, "IN865");Trait Implementations§
Source§impl Clone for OwnedChannelPlan
impl Clone for OwnedChannelPlan
Source§fn clone(&self) -> OwnedChannelPlan
fn clone(&self) -> OwnedChannelPlan
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more