Skip to main content

OwnedChannelPlan

Struct OwnedChannelPlan 

Source
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

Source

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));
Source

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

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Debug for OwnedChannelPlan

Source§

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

Formats the value using the given formatter. Read more

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