pub struct GuardCondition<'owner> { /* private fields */ }Expand description
Implementations§
Source§impl<'o> GuardCondition<'o>
impl<'o> GuardCondition<'o>
Sourcepub fn set(&mut self, triggered: bool) -> Result<()>
pub fn set(&mut self, triggered: bool) -> Result<()>
Sets the triggered state of this guard condition.
Setting to true unblocks any WaitSet this
condition is attached to. Setting to false resets it.
§Errors
Returns an Error if the condition failed to set.
§Examples
use cyclonedds::GuardCondition;
let mut guard_condition = GuardCondition::new(&participant)?;
guard_condition.set(true)?;Sourcepub fn read(&self) -> Result<bool>
pub fn read(&self) -> Result<bool>
Returns the current triggered state without clearing it.
§Errors
Returns an Error if the condition failed to read.
§Examples
use cyclonedds::GuardCondition;
let mut guard = GuardCondition::new(&participant)?;
guard.set(true)?;
assert_eq!(guard.read()?, true);
// State is preserved after read.
assert_eq!(guard.read()?, true);Sourcepub fn take(&mut self) -> Result<bool>
pub fn take(&mut self) -> Result<bool>
Returns the current triggered state and clears it.
Unlike read, this resets the triggered state
to false after returning it.
§Errors
Returns an Error if the condition failed to take.
§Examples
use cyclonedds::GuardCondition;
let mut guard = GuardCondition::new(&participant)?;
guard.set(true)?;
assert_eq!(guard.take()?, true);
// State has been cleared.
assert_eq!(guard.read()?, false);Trait Implementations§
Source§impl<'owner> Debug for GuardCondition<'owner>
impl<'owner> Debug for GuardCondition<'owner>
Source§impl Drop for GuardCondition<'_>
impl Drop for GuardCondition<'_>
Source§impl Entity for GuardCondition<'_>
impl Entity for GuardCondition<'_>
Source§fn instance_handle(&self) -> Result<InstanceHandle>
fn instance_handle(&self) -> Result<InstanceHandle>
Returns the
InstanceHandle of this entity. Read moreSource§fn status_changes(&self) -> Result<Status>
fn status_changes(&self) -> Result<Status>
Auto Trait Implementations§
impl<'owner> !RefUnwindSafe for GuardCondition<'owner>
impl<'owner> !Send for GuardCondition<'owner>
impl<'owner> !Sync for GuardCondition<'owner>
impl<'owner> !UnwindSafe for GuardCondition<'owner>
impl<'owner> Freeze for GuardCondition<'owner>
impl<'owner> Unpin for GuardCondition<'owner>
impl<'owner> UnsafeUnpin for GuardCondition<'owner>
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