Skip to main content

KernelBuilder

Struct KernelBuilder 

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

内核构建器,使用 Builder 模式配置内核参数。

§示例

ⓘ
let kernel = Kernel::builder()
    .config_from_str(toml_str)
    .with_protocol(Box::new(protocol))
    .with_connection_strategy(ConnectionStrategy::Persistent)
    .build();

Implementations§

Source§

impl KernelBuilder

Source

pub fn config_from_str(self, toml_str: &str) -> Self

从 TOML 字符串加载设备配置。

配置解析错误会保存到内核,并由 Kernel::boot 返回。

Source

pub fn config_from_file(self, path: impl AsRef<Path>) -> Self

从 TOML 文件加载设备配置。

配置加载错误会保存到内核,并由 Kernel::boot 返回。

Source

pub fn with_protocol(self, protocol: Box<dyn Protocol>) -> Self

注册一个协议实例。

Source

pub fn with_connection_strategy(self, strategy: ConnectionStrategy) -> Self

设置设备连接策略。

Source

pub fn with_event_capacity(self, cap: usize) -> Self

设置事件总线通道缓冲区大小。

Source

pub fn with_gateway_interval(self, ms: u64) -> Self

设置网关引擎的轮询间隔(毫秒)。

Source

pub fn build(self) -> Kernel

构建内核实例。

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.