MicrogridClientHandle

Struct MicrogridClientHandle 

Source
pub struct MicrogridClientHandle { /* private fields */ }
Expand description

A handle to the microgrid client connection.

This handle can be cloned as many times as needed, and each clone will share the same underlying connection to the microgrid API.

Implementations§

Source§

impl MicrogridClientHandle

Source

pub async fn try_new(url: impl Into<String>) -> Result<Self, Error>

Creates a new MicrogridClientHandle that connects to the microgrid API at the specified URL.

Source

pub fn new_from_client(client: impl MicrogridApiClient) -> Self

Source

pub async fn receive_electrical_component_telemetry_stream( &self, electrical_component_id: u64, ) -> Result<Receiver<ElectricalComponentTelemetry>, Error>

Returns a telemetry stream from an electrical component with a given ID.

When a connection to the API service is lost, reconnecting is handled automatically, and the receiver will resume receiving data from the component once the connection is re-established.

Source

pub async fn list_electrical_components( &self, electrical_component_ids: Vec<u64>, electrical_component_categories: Vec<i32>, ) -> Result<Vec<ElectricalComponent>, Error>

Lists the electrical components in the local microgrid.

If provided, the filters for component IDs and categories have an AND relationship with one another, meaning that they are applied serially, but the elements within a single filter list have an OR relationship with each other.

For example, if ids = [1, 2, 3], and categories = [ ComponentCategory::COMPONENT_CATEGORY_INVERTER, ComponentCategory::COMPONENT_CATEGORY_BATTERY ], then the results will consist of elements that have the IDs 1, OR 2, OR 3, AND are of the categories ComponentCategory::COMPONENT_CATEGORY_INVERTER OR ComponentCategory::COMPONENT_CATEGORY_BATTERY.

If a filter list is empty, then that filter is not applied.

Source

pub async fn list_electrical_component_connections( &self, source_electrical_component_ids: Vec<u64>, destination_electrical_component_ids: Vec<u64>, ) -> Result<Vec<ElectricalComponentConnection>, Error>

Lists the connections between the electrical components in a microgrid, denoted by (start, end).

The direction of a connection is always away from the grid endpoint, i.e. aligned with the direction of positive current according to the passive sign convention: https://en.wikipedia.org/wiki/Passive_sign_convention

If provided, the start and end filters have an AND relationship between each other, meaning that they are applied serially, but an OR relationship with other elements in the same list. For example, if start = [1, 2, 3], and end = [4, 5, 6], then the result should have all the connections where

  • each start component ID is either 1, 2, OR 3, AND
  • each end component ID is either 4, 5, OR 6.

Trait Implementations§

Source§

impl Clone for MicrogridClientHandle

Source§

fn clone(&self) -> MicrogridClientHandle

Returns a duplicate 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§

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> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

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

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

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 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
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.
Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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