smart_house_lib

Crates.iosmart_house_lib
lib.rssmart_house_lib
version0.3.2
sourcesrc
created_at2022-03-01 22:24:15.037571
updated_at2022-03-02 11:31:43.484691
descriptionIt's a simple library to course OTUS Rust developer
homepagehttps://github.com/zhuravlevma
repositoryhttps://github.com/zhuravlevma/smart-house-lib
max_upload_size
id541877
size39,932
Maksim Zhuravlev (zhuravlevma)

documentation

README

Simple library for smart house

smart_house_lib

[dependencies]
smart_house_lib = "0.3"

House

Create House

use smart_house_lib::{House};
let house = House::new("test_id".to_string(), "name".to_string());

Add apartment to house

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()));

Remove apartment from house

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());

Apartment

Create Apartment

use smart_house_lib::Apartment;
let apartment = Apartment::new("name".to_string());

Add devices to apartment

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);

Remove device from apartment

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());

Device

Create device

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()));

Create rosette

use smart_house_lib::Rosette;
let rosette = Rosette::new("name".to_string(), "127.0.0.1:9091".to_string());

Create thermometer

use smart_house_lib::Thermometer;
let thermometer = Thermometer::new("name".to_string(), 23.0, "127.0.0.1:9091".to_string());

License

This project is licensed under the MIT license.

Commit count: 176

cargo fmt