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.
§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
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 moreAuto Trait Implementations§
impl Freeze for OwnedChannelPlan
impl RefUnwindSafe for OwnedChannelPlan
impl Send for OwnedChannelPlan
impl Sync for OwnedChannelPlan
impl Unpin for OwnedChannelPlan
impl UnsafeUnpin for OwnedChannelPlan
impl UnwindSafe for OwnedChannelPlan
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