3个版本
0.3.2 | 2022年3月2日 |
---|---|
0.3.1 | 2022年3月2日 |
0.3.0 | 2022年3月1日 |
#682 in 硬件支持
52KB
1K SLoC
智能家居简单库
smart_house_lib
[dependencies]
smart_house_lib = "0.3"
房屋
创建房屋
use smart_house_lib::{House};
let house = House::new("test_id".to_string(), "name".to_string());
将公寓添加到房屋
use smart_house_lib::{House, Apartment};
let mut house = House::new("test_id".to_string(), "name".to_string());
house.add_apartment(Apartment::new("name".to_string()));
从房屋中删除公寓
use smart_house_lib::{House, Apartment};
let mut house = House::new("test_id".to_string(), "name".to_string());
house.add_apartment(Apartment::new("name".to_string()));
house.remove_apartment("name".to_string());
公寓
创建公寓
use smart_house_lib::Apartment;
let apartment = Apartment::new("name".to_string());
将设备添加到公寓
use smart_house_lib::{Apartment, Device, Rosette};
let mut apartment = Apartment::new("name".to_string());
let device = Device::Rosette(Rosette::new("test".to_string(), "127.0.0.1:8080".to_string()));
apartment.add_device(device);
从公寓中删除设备
use smart_house_lib::{Apartment, Device, Rosette};
let mut apartment = Apartment::new("name".to_string());
let device = Device::Rosette(Rosette::new("test".to_string(), "127.0.0.1:8080".to_string()));
apartment.add_device(device);
apartment.remove_device("test".to_string());
设备
创建设备
use smart_house_lib::{Device, Rosette, Thermometer};
let thermometer = Device::Thermometer(Thermometer::new("name".to_string(), 23.0, "127.0.0.1:9091".to_string()));
let rosette = Device::Rosette(Rosette::new("name".to_string(), "127.0.0.1:8081".to_string()));
创建玫瑰
use smart_house_lib::Rosette;
let rosette = Rosette::new("name".to_string(), "127.0.0.1:9091".to_string());
创建温度计
use smart_house_lib::Thermometer;
let thermometer = Thermometer::new("name".to_string(), 23.0, "127.0.0.1:9091".to_string());
许可证
此项目采用MIT许可证。
依赖项
~2.9–9.5MB
~83K SLoC