pub struct Storage { /* private fields */ }
Expand description
Reads and syncs with rooms.json
in RIZ_STORAGE_PATH
(env var)
Expected to be wrapped by a std::sync::Mutex, then wrapped with a actix_web::web::Data, and cloned to each request
NB: All &mut
methods update the contents of rooms.json
§Examples
use std::sync::Mutex;
use actix_web::web::Data;
use riz::Storage;
let storage = Data::new(Mutex::new(Storage::new()));
Implementations§
Source§impl Storage
impl Storage
Sourcepub fn new_light(&mut self, room: &Uuid, light: Light) -> Result<Uuid>
pub fn new_light(&mut self, room: &Uuid, light: Light) -> Result<Uuid>
Create a new light in the room
Sourcepub fn update_room(&mut self, id: &Uuid, room: &Room) -> Result<()>
pub fn update_room(&mut self, id: &Uuid, room: &Room) -> Result<()>
Updates non-light attributes (currently just name)
Sourcepub fn update_light(
&mut self,
id: &Uuid,
light_id: &Uuid,
light: &Light,
) -> Result<()>
pub fn update_light( &mut self, id: &Uuid, light_id: &Uuid, light: &Light, ) -> Result<()>
Update non-lighting attributes of the light in the room (name, ip)
Sourcepub fn delete_room(&mut self, room: &Uuid) -> Result<()>
pub fn delete_room(&mut self, room: &Uuid) -> Result<()>
Remove a room
Sourcepub fn delete_light(&mut self, room: &Uuid, light: &Uuid) -> Result<()>
pub fn delete_light(&mut self, room: &Uuid, light: &Uuid) -> Result<()>
Remove a light in a room
Sourcepub fn process_reply(&mut self, resp: &LightingResponse)
pub fn process_reply(&mut self, resp: &LightingResponse)
Process the response of a lighting request
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Storage
impl RefUnwindSafe for Storage
impl Send for Storage
impl Sync for Storage
impl Unpin for Storage
impl UnwindSafe for Storage
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