pub struct ThreeTuple {
pub product_key: String,
pub device_name: String,
pub device_secret: String,
}
Expand description
设备认证三元组。
这个三元组除了在一型一密的动态注册中用不到之外,所有和阿里云物联网平台发起的连接都要有这三元组生成签名。
Fields§
§product_key: String
产品 ProductKey,即所谓”型“。参考创建产品。
device_name: String
设备 DeviceName,即所谓”机“。参考创建设备。
device_secret: String
Implementations§
Source§impl ThreeTuple
impl ThreeTuple
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
从下列环境变量中读取三元组。
PRODUCT_KEY
DEVICE_NAME
DEVICE_SECRET
这个方法在示例代码中多处用到,但实际生产环境中建议自行编写初始化逻辑。
§Examples
std::env::set_var("PRODUCT_KEY", "a");
std::env::set_var("DEVICE_NAME", "b");
std::env::set_var("DEVICE_SECRET", "c");
use aiot::ThreeTuple;
let three = ThreeTuple::from_env();
assert_eq!("a", &three.product_key);
assert_eq!("b", &three.device_name);
assert_eq!("c", &three.device_secret);
§Panics
如果没有设置对应的环境变量,该方法将 panic。
Trait Implementations§
Source§impl Clone for ThreeTuple
impl Clone for ThreeTuple
Source§fn clone(&self) -> ThreeTuple
fn clone(&self) -> ThreeTuple
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ThreeTuple
impl Debug for ThreeTuple
Source§impl Default for ThreeTuple
impl Default for ThreeTuple
Source§fn default() -> ThreeTuple
fn default() -> ThreeTuple
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ThreeTuple
impl RefUnwindSafe for ThreeTuple
impl Send for ThreeTuple
impl Sync for ThreeTuple
impl Unpin for ThreeTuple
impl UnwindSafe for ThreeTuple
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more