Skip to main content

DriverFactory

Struct DriverFactory 

Source
pub struct DriverFactory;
Expand description

Driver factory using factory pattern 使用工厂模式的Driver工厂

Provides a unified interface for creating different driver implementations. 提供用于创建不同driver实现的统一接口。

Implementations§

Source§

impl DriverFactory

Source

pub fn create(driver_type: DriverType) -> Result<Arc<dyn Driver>>

Create a driver with the specified type and default configuration 使用指定类型和默认配置创建driver

§Errors / 错误

Returns an error if: 返回错误如果:

  • The specified driver type is not available on this platform
  • 指定的driver类型在此平台上不可用
  • Driver initialization fails
  • Driver初始化失败
§Examples / 示例
use hiver_runtime::driver::{DriverFactory, DriverType};

let driver = DriverFactory::create(DriverType::Auto).unwrap();
Source

pub fn create_with_config( driver_type: DriverType, config: DriverConfig, ) -> Result<Arc<dyn Driver>>

Create a driver with the specified type and configuration 使用指定类型和配置创建driver

§Errors / 错误

Returns an error if driver initialization fails. 如果driver初始化失败则返回错误。

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.