Skip to main content

BlockingReader

Struct BlockingReader 

Source
pub struct BlockingReader<'a, T, P, const N: usize = 1024> { /* private fields */ }
Expand description

Read attributes through an established client over BudgetedTransport. The host authenticates the meter and sets transport deadlines. Scratch must fit the complete encoded A-XDR value, which the result borrows directly. On a capacity error use BlockingReadError::requires_reconnect before retrying.

use core::num::NonZeroUsize;
use smgw_lmn::dlms::{self, BlockingReadError, BlockingReader, BudgetedTransport, ClockRange, Counts, ReadError, Source};
use smgw_core::taf15;
use dlms::protocol::{client::{Client, ClientConfig, ClientError, Transport}, security::CryptoProvider};

fn connect<T: Transport, P: CryptoProvider>(
    transport: T, config: ClientConfig, provider: P, wire_budget: NonZeroUsize,
) -> Result<Client<BudgetedTransport<T>, P>, ClientError> {
    Client::connect(BudgetedTransport::new(transport, wire_budget), config, provider)
}

fn backfill<T: Transport, P: CryptoProvider, const FRAME: usize, const SLOTS: usize>(
    client: &mut Client<BudgetedTransport<T>, P, FRAME>,
    authenticated_meter_id: &str,
    source: &Source<'_>,
    destination: &mut taf15::Profile<'_, SLOTS>,
    range: ClockRange,
    scratch: &mut [u8],
) -> Result<Counts, ReadError<BlockingReadError>> {
    let mut reader = BlockingReader::new(authenticated_meter_id, client, scratch);
    dlms::read_profile(&mut reader, source, range, destination)
}

Implementations§

Source§

impl<'a, T, P, const N: usize> BlockingReader<'a, T, P, N>

Source

pub fn new( meter_id: &'a str, client: &'a mut Client<BudgetedTransport<T>, P, N>, scratch: &'a mut [u8], ) -> Self

Bind the identity established by the host to its associated client.

Trait Implementations§

Source§

impl<T: Transport, P: CryptoProvider, const N: usize> AttributeReader for BlockingReader<'_, T, P, N>

Source§

type Error = BlockingReadError

Source§

fn meter_id(&self) -> &str

Identity bound to this association by the caller at commissioning.
Source§

fn get( &mut self, attribute: AttributeDescriptor, selection: Option<SelectiveAccess<'_>>, ) -> Result<Data<'_>, BlockingReadError>

Read exactly this attribute and selection. Propagate transport and meter refusals.

Auto Trait Implementations§

§

impl<'a, T, P, const N: usize = 1024> !UnwindSafe for BlockingReader<'a, T, P, N>

§

impl<'a, T, P, const N: usize> Freeze for BlockingReader<'a, T, P, N>

§

impl<'a, T, P, const N: usize> RefUnwindSafe for BlockingReader<'a, T, P, N>

§

impl<'a, T, P, const N: usize> Send for BlockingReader<'a, T, P, N>
where T: Send, P: Send,

§

impl<'a, T, P, const N: usize> Sync for BlockingReader<'a, T, P, N>
where T: Sync, P: Sync,

§

impl<'a, T, P, const N: usize> Unpin for BlockingReader<'a, T, P, N>

§

impl<'a, T, P, const N: usize> UnsafeUnpin for BlockingReader<'a, T, P, N>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.