Struct iot_device_bridge::device_shadow::DeviceShadow
source · [−]pub struct DeviceShadow { /* private fields */ }
Expand description
DeviceShadow holds the attributes for handling a shadow
- shadow_value : JSON values of the shadow
- eventloop_handle : handle for communocating with the cloud shadow
- shadow_topic : ShadowTopic
Implementations
sourceimpl DeviceShadow
impl DeviceShadow
pub fn new(
thing_name: String,
shadow_type: ShadowType,
eventloop_handle: Sender<Request>
) -> Self
sourcepub fn get_prefix(&self) -> String
pub fn get_prefix(&self) -> String
Get Device Shadow prefix, e.g., AWS specific
sourcepub fn get_shadow_topic(&self) -> ShadowTopic
pub fn get_shadow_topic(&self) -> ShadowTopic
Get Device Shadow topic, e.g., AWS specific.
sourcepub fn get_shadow_name_from_aws_topic(&self, aws_topic: &String) -> String
pub fn get_shadow_name_from_aws_topic(&self, aws_topic: &String) -> String
Get Shadow Name from topic, e.g., “$aws/things/{}/shadow/name/{}/”
sourcepub fn build_shadow_message_update(
&self,
shadow_value: String,
reported_only: bool
) -> IotMessage
pub fn build_shadow_message_update(
&self,
shadow_value: String,
reported_only: bool
) -> IotMessage
Builds either UPDATE reported or UPDATE desired-and-reported Iot Message
sourcepub async fn retrieve_shadow_delivery(
&mut self,
event: &Publish
) -> Result<(&str, Value), IoTError>
pub async fn retrieve_shadow_delivery(
&mut self,
event: &Publish
) -> Result<(&str, Value), IoTError>
The retrieve_shadow_delivery
function
- performs actions on the general DeviceShadow
- stores the delivered payload
- returns following sub-branch to be processed by device specific function
a. ResponseUPDATE_ACCEPTED
:state.desired.*
b. ResponseUPDATE_DELTA
:state.*
c. ResponseUPDATE_DOCUMENTS
:current.state.desired.*
d. ResponseGET_ACCEPTED
:state.desired.*
e. all other responses returnserde_json::Value::Null
Remark: The device specific processing of the “documents”, “delta” and “update” shadow responses (particularly containing incremental changes only) will be done in the Device Adapter.
sourcepub async fn initiate_shadow(
&self,
eventloop: &mut EventLoop,
xmit: Xmit<IotMessage>,
shadow_initial_update: String
) -> Result<(), IoTError>
pub async fn initiate_shadow(
&self,
eventloop: &mut EventLoop,
xmit: Xmit<IotMessage>,
shadow_initial_update: String
) -> Result<(), IoTError>
Helper function to
- subscribe to all prefixes of a DeviceShadow and
- initiate GET of the remote shadow by sending the message to the IoT sender via MPSC channel
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for DeviceShadow
impl Send for DeviceShadow
impl Sync for DeviceShadow
impl Unpin for DeviceShadow
impl UnwindSafe for DeviceShadow
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more