Struct sep2_client::client::Client

source ·
pub struct Client { /* private fields */ }
Expand description

Represents an IEEE 2030.5 Client connection to a single server

Can be cloned cheaply as poll tasks, and the underlying hyper connection pool are shared between cloned clients.

Implementations§

source§

impl Client

source

pub fn new( server_addr: &str, tcp_keepalive: Option<Duration>, tickrate: Option<Duration> ) -> Result<Self>

Construct an IEEE 2030.5 Client instance that uses HTTP

TCP KeepAlive:

Pass the given value to SO_KEEPALIVE.

Tickrate:

Set how often the client background task should wakeup to check the polling queue.

Defaults to 10 minutes, if this function is not called.

If Client::start_poll is never called, this setting has no effect.

source

pub fn new_https( server_addr: &str, cert_path: impl AsRef<Path>, pk_path: impl AsRef<Path>, rootca_path: impl AsRef<Path>, tcp_keepalive: Option<Duration>, tickrate: Option<Duration> ) -> Result<Self>

Construct an IEEE 2030.5 Client instance that uses HTTPS

source

pub async fn get<R: SEResource>(&self, path: &str) -> Result<R>

Retrieve the SEResource at the given relative path.

Returns an error if the resource could not be retrieved or deserialized.

source

pub async fn post<R: SEResource>( &self, path: &str, resource: &R ) -> Result<SEPResponse>

Update a SEResource at the given relative path.

Returns an error if the server does not respond with 204 No Content or 201 Created.

source

pub async fn put<R: SEResource>( &self, path: &str, resource: &R ) -> Result<SEPResponse>

Create a SEResource at the given relative path.

Returns an error if the server does not respond with 204 No Content or 201 Created.

source

pub async fn delete(&self, path: &str) -> Result<SEPResponse>

Delete the SEResource at the given relative path.

Returns an error if the server does not respond with 204 No Content.

source

pub async fn start_poll<T>( &self, path: impl Into<String>, poll_rate: Option<Uint32>, callback: impl PollCallback<T> )where T: SEResource,

Begin polling the given route by performing GET requests on a regular interval. Passes the returned SEResource to the given callback.

The callback will not be run if the GET request fails, or the resource cannot be deserialized.

As per IEEE 2030.5, if a poll rate is not specified, a default of 900 seconds (15 minutes) is used.

All poll events created can be forcibly run using Client::force_polls, such as is required when reconnecting to the server after a period of connectivity loss.

source

pub async fn force_polls(&self)

Forcibly poll & run the callbacks of all routes polled using Client::start_poll

source

pub async fn cancel_polls(&self)

Cancel all poll tasks created using Client::start_poll

source

pub async fn send_msg_response( &self, lfdi: HexBinary160, event: &TextMessage, status: ResponseStatus, time: SEPTime ) -> Result<SEPResponse>

Available on crate feature messaging only.
source

pub async fn send_der_response( &self, lfdi: HexBinary160, event: &DERControl, status: ResponseStatus, time: SEPTime ) -> Result<SEPResponse>

Available on crate feature der only.
source

pub async fn send_drlc_response( &self, device: &SEDevice, event: &EndDeviceControl, status: ResponseStatus, time: SEPTime ) -> Result<SEPResponse>

Available on crate feature drlc only.
source

pub async fn send_pricing_response( &self, lfdi: HexBinary160, event: &TimeTariffInterval, status: ResponseStatus, time: SEPTime ) -> Result<SEPResponse>

Available on crate feature pricing only.

Trait Implementations§

source§

impl Clone for Client

source§

fn clone(&self) -> Client

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more