Skip to main content

DataAcc

Trait DataAcc 

Source
pub trait DataAcc {
    // Required method
    fn get_data_conn<C: DataConn + 'static>(
        &mut self,
        name: impl AsRef<str>,
    ) -> Result<&mut C>;
}
Expand description

This trait provides a mechanism to retrieve a mutable reference to a DataConn object by name, creating it if necessary.

It is typically implemented as a derived trait with default methods (using the override_macro crate) on DataHub, allowing application logic to interact with data services through an abstract interface.

Required Methods§

Source

fn get_data_conn<C: DataConn + 'static>( &mut self, name: impl AsRef<str>, ) -> Result<&mut C>

Retrieves a mutable reference to a DataConn object by name, creating it if necessary.

This is the core method used by DataAcc implementations to obtain connections to external data services. It first checks if a DataConn with the given name already exists in the current session. If not, it attempts to find a corresponding DataSrc and create a new DataConn from it.

§Type Parameters
  • C: The concrete type of DataConn expected.
§Parameters
  • name: The name of the data source/connection to retrieve.
§Returns
  • errs::Result<&mut C>: A mutable reference to the DataConn instance if successful, or an errs::Err if the data source is not found, or if the retrieved/created DataConn cannot be cast to the specified type C.

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.

Implementors§