Trait GCGatewayInterface
pub trait GCGatewayInterface: Send + Sync {
Show 23 methods
// Required methods
fn start_async_broker(&self);
fn start_plugin(
&self,
plugin_instance_name: &str,
) -> Result<(), GCGatewayError>;
fn start_all_plugins(&self) -> Vec<String>;
fn stop_plugin_instance(
&self,
plugin_instance_name: &str,
) -> Result<(), GCGatewayError>;
fn update_plugin_instance(
&self,
plugin_instance_name: &str,
config: GCControllerPluginInstanceConfig,
) -> Result<(), GCGatewayError>;
fn remove_plugin_instance(
&self,
plugin_instance_name: &str,
) -> Result<(), GCGatewayError>;
fn register_plugin_publisher(
&self,
plugin_instance_name: &str,
datapoint_id: GCDatapointID,
) -> Result<(), GCGatewayError>;
fn register_plugin_subscriber(
&self,
plugin_instance_name: &str,
datapoint_id: GCDatapointID,
concurrent: bool,
) -> Result<(), GCGatewayError>;
fn unregister_publisher(
&self,
plugin_instance_name: &str,
datapoint_id: GCDatapointID,
) -> bool;
fn unregister_subscriber(
&self,
plugin_instance_name: &GCSubscriberIdentifier,
datapoint_id: GCDatapointID,
) -> bool;
fn update_datapoint(
&self,
datapoint_id: GCDatapointID,
metadata: GCDatapointMetadata,
) -> Result<Vec<String>, GCGatewayError>;
fn add_datapoint(
&self,
datapoint_id: GCDatapointID,
metadata: GCDatapointMetadata,
) -> Result<(), GCGatewayError>;
fn remove_datapoint(
&self,
datapoint_id: GCDatapointID,
) -> Result<(), GCGatewayError>;
fn add_plugin_instance(
&self,
instance_name: &str,
plugin_path: &str,
instance_config: GCControllerPluginInstanceConfig,
) -> Result<(), GCGatewayError>;
fn publish_datapoint(
&self,
dpv: GCDatapointValue,
) -> Result<(), GCGatewayError>;
fn get_datapoints_info<T: Iterator<Item = GCDatapointID>>(
&self,
datapoint_ids: Option<T>,
) -> Vec<(GCDatapointID, GCDatapointConfig)>;
fn get_plugins_info(&self) -> Vec<GCPluginInstanceInfo>;
fn get_latest_values<T: for<'a> TryFrom<(String, &'a GCDatapointValue)>>(
&self,
dp_ids: impl Iterator<Item = GCDatapointID>,
) -> Vec<T>;
fn get_buffered_values<T: for<'a> TryFrom<&'a GCDatapointValue>>(
&self,
dp_ids: impl Iterator<Item = GCDatapointID>,
) -> HashMap<String, Vec<T>>;
fn upsert_runtime_subscription<T: Iterator<Item = GCDatapointID>>(
&self,
subscriber: Arc<dyn GCDatapointSubscriber>,
datapoint_ids: T,
);
fn remove_runtime_subscription(
&self,
subscriber_id: GCSubscriberIdentifier,
datapoint_ids: &[GCDatapointID],
);
fn get_broker_publisher(&self) -> GCMessagePublisher;
fn set_device_config(
&self,
config: DeviceConfig,
) -> Result<(), GCGatewayError>;
}Expand description
The main interface for managing the Gateway, including adding datapoints, managing plugins, and handling the message broker. This can be used to create mock implementations for testing purposes.
Required Methods§
fn start_async_broker(&self)
fn start_async_broker(&self)
Starts the concurrent message broker.
fn start_plugin(&self, plugin_instance_name: &str) -> Result<(), GCGatewayError>
fn start_plugin(&self, plugin_instance_name: &str) -> Result<(), GCGatewayError>
Starts a plugin instance that is not yet running.
If the plugin instance is already running, this method returns an error.
fn start_all_plugins(&self) -> Vec<String>
fn start_all_plugins(&self) -> Vec<String>
Starts all plugin instances that are not yet running. Returns a list of all plugins that were started successfully. If a plugin fails to start, it will not prevent other plugins from starting.
fn stop_plugin_instance(
&self,
plugin_instance_name: &str,
) -> Result<(), GCGatewayError>
fn stop_plugin_instance( &self, plugin_instance_name: &str, ) -> Result<(), GCGatewayError>
Stops a plugin instance that is running.
fn update_plugin_instance(
&self,
plugin_instance_name: &str,
config: GCControllerPluginInstanceConfig,
) -> Result<(), GCGatewayError>
fn update_plugin_instance( &self, plugin_instance_name: &str, config: GCControllerPluginInstanceConfig, ) -> Result<(), GCGatewayError>
Updates a plugin instance’s configuration.
If the plugin is already running, this will only take effect after it is restarted.
fn remove_plugin_instance(
&self,
plugin_instance_name: &str,
) -> Result<(), GCGatewayError>
fn remove_plugin_instance( &self, plugin_instance_name: &str, ) -> Result<(), GCGatewayError>
Remove a plugin instance. If the plugin instance is running, it will be stopped before being deleted.
fn register_plugin_publisher(
&self,
plugin_instance_name: &str,
datapoint_id: GCDatapointID,
) -> Result<(), GCGatewayError>
fn register_plugin_publisher( &self, plugin_instance_name: &str, datapoint_id: GCDatapointID, ) -> Result<(), GCGatewayError>
Registers a plugin instance as a publisher to a datapoint. This will only be visible to the plugin after it is restarted.
fn register_plugin_subscriber(
&self,
plugin_instance_name: &str,
datapoint_id: GCDatapointID,
concurrent: bool,
) -> Result<(), GCGatewayError>
fn register_plugin_subscriber( &self, plugin_instance_name: &str, datapoint_id: GCDatapointID, concurrent: bool, ) -> Result<(), GCGatewayError>
Registers a plugin instance as a subscriber to a datapoint. The plugin may start receiving new datapoint values immediately but will not be able to see the datapoint in the interface once it is restarted. If concurrent is set to true, the plugin will be registered as a concurrent aka async subscriber.
fn unregister_publisher(
&self,
plugin_instance_name: &str,
datapoint_id: GCDatapointID,
) -> bool
fn unregister_publisher( &self, plugin_instance_name: &str, datapoint_id: GCDatapointID, ) -> bool
Unregister a plugin instance as a publisher to a datapoint. If the plugin is not registered as a publisher, this method returns false
fn unregister_subscriber(
&self,
plugin_instance_name: &GCSubscriberIdentifier,
datapoint_id: GCDatapointID,
) -> bool
fn unregister_subscriber( &self, plugin_instance_name: &GCSubscriberIdentifier, datapoint_id: GCDatapointID, ) -> bool
Unregister a plugin instance as a subscriber to a datapoint. If the plugin is not registered as a subscriber, this method returns false
fn update_datapoint(
&self,
datapoint_id: GCDatapointID,
metadata: GCDatapointMetadata,
) -> Result<Vec<String>, GCGatewayError>
fn update_datapoint( &self, datapoint_id: GCDatapointID, metadata: GCDatapointMetadata, ) -> Result<Vec<String>, GCGatewayError>
Updates the metadata of a datapoint that already exists. Plugins that are subscribed or published to this datapoint will be returned. The plugins will only be able to see the new metadata after they are restarted.
If the datapoint does not exist, returns an error.
fn add_datapoint(
&self,
datapoint_id: GCDatapointID,
metadata: GCDatapointMetadata,
) -> Result<(), GCGatewayError>
fn add_datapoint( &self, datapoint_id: GCDatapointID, metadata: GCDatapointMetadata, ) -> Result<(), GCGatewayError>
Adds a new datapoint. If the datapoint already exists, returns an error.
fn remove_datapoint(
&self,
datapoint_id: GCDatapointID,
) -> Result<(), GCGatewayError>
fn remove_datapoint( &self, datapoint_id: GCDatapointID, ) -> Result<(), GCGatewayError>
Removes a datapoint. If the datapoint does not exist, an error will NOT be returned. This will have the following effects:
- RealtimeDatabase: The values related to the datapoint are set to the default and it is also set as uninitialized.
- MessageBroker: Nothing is done here.
- ConfigDatabase: The datapoint is removed from the database.
Returns an error if:
- The datapoint is marked as a subscriber of any plugin instance.
- The datapoint is marked as a publisher of any plugin instance.
fn add_plugin_instance(
&self,
instance_name: &str,
plugin_path: &str,
instance_config: GCControllerPluginInstanceConfig,
) -> Result<(), GCGatewayError>
fn add_plugin_instance( &self, instance_name: &str, plugin_path: &str, instance_config: GCControllerPluginInstanceConfig, ) -> Result<(), GCGatewayError>
Adds a new plugin instance. The dll will be loaded and the plugin instance will be created (but not started) Returns an error if the plugin instance already exists or the dll could not be loaded.
fn publish_datapoint(&self, dpv: GCDatapointValue) -> Result<(), GCGatewayError>
fn publish_datapoint(&self, dpv: GCDatapointValue) -> Result<(), GCGatewayError>
Publishes a value to a datapoint.
Prefer using get_broker_publisher for frequent datapoint values.
fn get_datapoints_info<T: Iterator<Item = GCDatapointID>>(
&self,
datapoint_ids: Option<T>,
) -> Vec<(GCDatapointID, GCDatapointConfig)>
fn get_datapoints_info<T: Iterator<Item = GCDatapointID>>( &self, datapoint_ids: Option<T>, ) -> Vec<(GCDatapointID, GCDatapointConfig)>
Gets the list of datapoints that exist in the database.
fn get_plugins_info(&self) -> Vec<GCPluginInstanceInfo>
fn get_plugins_info(&self) -> Vec<GCPluginInstanceInfo>
Gets the list of plugin instances that exist in the database.
fn get_latest_values<T: for<'a> TryFrom<(String, &'a GCDatapointValue)>>(
&self,
dp_ids: impl Iterator<Item = GCDatapointID>,
) -> Vec<T>
fn get_latest_values<T: for<'a> TryFrom<(String, &'a GCDatapointValue)>>( &self, dp_ids: impl Iterator<Item = GCDatapointID>, ) -> Vec<T>
Get latest datapoint values
fn get_buffered_values<T: for<'a> TryFrom<&'a GCDatapointValue>>(
&self,
dp_ids: impl Iterator<Item = GCDatapointID>,
) -> HashMap<String, Vec<T>>
fn get_buffered_values<T: for<'a> TryFrom<&'a GCDatapointValue>>( &self, dp_ids: impl Iterator<Item = GCDatapointID>, ) -> HashMap<String, Vec<T>>
Get latest buffered values
fn upsert_runtime_subscription<T: Iterator<Item = GCDatapointID>>(
&self,
subscriber: Arc<dyn GCDatapointSubscriber>,
datapoint_ids: T,
)
fn upsert_runtime_subscription<T: Iterator<Item = GCDatapointID>>( &self, subscriber: Arc<dyn GCDatapointSubscriber>, datapoint_ids: T, )
Adds a new subscription, subscriptions added through this method are not registered in the configuration metadata.
Thus, are not returned by the get_datapoints_info method.
Attempting to add a subscriber with the identifier of an already loaded plugin subscription will cause an error.
fn remove_runtime_subscription(
&self,
subscriber_id: GCSubscriberIdentifier,
datapoint_ids: &[GCDatapointID],
)
fn remove_runtime_subscription( &self, subscriber_id: GCSubscriberIdentifier, datapoint_ids: &[GCDatapointID], )
Removes a subscription by id
Attempting to remove a subscription with the identifier of an plugin subscription (present in the config database) will cause an error.
fn get_broker_publisher(&self) -> GCMessagePublisher
fn get_broker_publisher(&self) -> GCMessagePublisher
Returns the message broker publisher used by the controller.
fn set_device_config(&self, config: DeviceConfig) -> Result<(), GCGatewayError>
fn set_device_config(&self, config: DeviceConfig) -> Result<(), GCGatewayError>
Sets the device configuration for the runtime. This configuration will be stored and applied to the OS.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.