Skip to main content

GCConfigDatabase

Struct GCConfigDatabase 

pub struct GCConfigDatabase {
    datapoint_db: HashMap<GCDatapointID, GCDatapointConfig>,
    plugin_db: HashMap<String, Value>,
}
Expand description

A database that stores the metadata of the datapoints and the config of the plugins.

Fields§

§datapoint_db: HashMap<GCDatapointID, GCDatapointConfig>§plugin_db: HashMap<String, Value>

Implementations§

§

impl GCConfigDatabase

pub fn new() -> Self

pub fn get_datapoint( &self, datapoint_id: GCDatapointID, ) -> Option<&GCDatapointConfig>

Returns a copy of the metadata of the datapoint.

pub fn get_datapoint_by_name( &self, name: &str, ) -> Option<(GCDatapointID, &GCDatapointConfig)>

Returns the datapoint by name. Time complexity: O(n)

pub fn upsert_datapoint( &mut self, datapoint_id: GCDatapointID, metadata: GCDatapointConfig, )

Adds a datapoint to the database.

pub fn get_datapoints_subscribed_by_plugin<'a>( &'a self, plugin_name: &'a str, ) -> impl Iterator<Item = (GCDatapointID, &'a GCDatapointConfig)> + 'a

Get all datapoints that have a specific plugin as subscriber

pub fn get_datapoints_published_by_plugin<'a>( &'a self, plugin_name: &'a str, ) -> impl Iterator<Item = (GCDatapointID, &'a GCDatapointConfig)> + 'a

Get all datapoints that have a specific plugin as publisher

pub fn update_datapoint<T: FnOnce(&mut GCDatapointConfig)>( &mut self, datapoint_id: GCDatapointID, update_fn: T, ) -> Result<(), GCGatewayError>

Update metadata, if it does not exist returns an error

pub fn get_plugin_config(&self, plugin_key: &str) -> Option<&JsonValue>

Get plugin config

pub fn update_plugin( &mut self, plugin_key: String, plugin_config: JsonValue, ) -> Result<(), GCGatewayError>

Update plugin

pub fn upsert_plugin(&mut self, plugin_key: String, config: JsonValue)

Upsert plugin config

pub fn datapoint_iter( &self, ) -> impl Iterator<Item = (GCDatapointID, &GCDatapointConfig)>

Iterates over all datapoints

pub fn get_plugin_instance_config( &self, plugin_instance_name: &str, ) -> Option<GCPluginInstanceConfig<'_>>

Returns a plugin instance config

pub fn remove_plugin_instance(&mut self, plugin_instance_name: &str)

Removes a plugin instance if it exists

pub fn remove_datapoint(&mut self, datapoint_id: GCDatapointID)

Removes a datapoint if it exists

pub fn unregister_subscriber( &mut self, plugin_instance_name: &str, datapoint_id: GCDatapointID, ) -> bool

Unregister subscription

pub fn unregister_publisher( &mut self, plugin_instance_name: &str, datapoint_id: GCDatapointID, ) -> bool

Unregister publication

Trait Implementations§

§

impl DatapointNameResolver for GCConfigDatabase

Resolves a datapoint ID into it’s configured name

§

fn name_for(&self, id: GCDatapointID) -> &str

§

impl Default for GCConfigDatabase

§

fn default() -> GCConfigDatabase

Returns the “default value” for a type. 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> 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, 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.
§

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

§

fn vzip(self) -> V