More ergonomic api when STD is available
This commit is contained in:
parent
505fa39e82
commit
688d7ea8d5
3 changed files with 17 additions and 2 deletions
|
@ -54,6 +54,14 @@ pub struct Matter<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Matter<'a> {
|
impl<'a> Matter<'a> {
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
pub fn new_default(dev_det: &'a BasicInfoConfig, mdns: &'a mut dyn Mdns) -> Self {
|
||||||
|
use crate::utils::epoch::{sys_epoch, sys_utc_calendar};
|
||||||
|
use crate::utils::rand::sys_rand;
|
||||||
|
|
||||||
|
Self::new(dev_det, mdns, sys_epoch, sys_rand, sys_utc_calendar)
|
||||||
|
}
|
||||||
|
|
||||||
/// Creates a new Matter object
|
/// Creates a new Matter object
|
||||||
///
|
///
|
||||||
/// # Parameters
|
/// # Parameters
|
||||||
|
|
|
@ -191,18 +191,18 @@ impl<'a> TransportMgr<'a> {
|
||||||
pub fn new<
|
pub fn new<
|
||||||
T: Borrow<RefCell<FabricMgr>>
|
T: Borrow<RefCell<FabricMgr>>
|
||||||
+ Borrow<RefCell<PaseMgr>>
|
+ Borrow<RefCell<PaseMgr>>
|
||||||
|
+ Borrow<RefCell<MdnsMgr<'a>>>
|
||||||
+ Borrow<Epoch>
|
+ Borrow<Epoch>
|
||||||
+ Borrow<Rand>
|
+ Borrow<Rand>
|
||||||
+ Borrow<UtcCalendar>,
|
+ Borrow<UtcCalendar>,
|
||||||
>(
|
>(
|
||||||
matter: &'a T,
|
matter: &'a T,
|
||||||
mdns_mgr: &'a RefCell<MdnsMgr<'a>>,
|
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self::wrap(
|
Self::wrap(
|
||||||
SecureChannel::new(
|
SecureChannel::new(
|
||||||
matter.borrow(),
|
matter.borrow(),
|
||||||
matter.borrow(),
|
matter.borrow(),
|
||||||
mdns_mgr,
|
matter.borrow(),
|
||||||
*matter.borrow(),
|
*matter.borrow(),
|
||||||
*matter.borrow(),
|
*matter.borrow(),
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
pub type Rand = fn(&mut [u8]);
|
pub type Rand = fn(&mut [u8]);
|
||||||
|
|
||||||
pub fn dummy_rand(_buf: &mut [u8]) {}
|
pub fn dummy_rand(_buf: &mut [u8]) {}
|
||||||
|
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
pub fn sys_rand(buf: &mut [u8]) {
|
||||||
|
use rand::{thread_rng, RngCore};
|
||||||
|
|
||||||
|
thread_rng().fill_bytes(buf);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue