Trait statime::PtpInstanceStateMutex

source ·
pub trait PtpInstanceStateMutex {
    // Required methods
    fn new(state: PtpInstanceState) -> Self;
    fn with_ref<R, F: FnOnce(&PtpInstanceState) -> R>(&self, f: F) -> R;
    fn with_mut<R, F: FnOnce(&mut PtpInstanceState) -> R>(&self, f: F) -> R;
}
Expand description

A mutex over a PtpInstanceState

This provides an abstraction for locking state in various environments. Implementations are provided for core::cell::RefCell and std::sync::RwLock.

Required Methods§

source

fn new(state: PtpInstanceState) -> Self

Creates a new instance of the mutex

source

fn with_ref<R, F: FnOnce(&PtpInstanceState) -> R>(&self, f: F) -> R

Takes a shared reference to the contained state and calls f with it

source

fn with_mut<R, F: FnOnce(&mut PtpInstanceState) -> R>(&self, f: F) -> R

Takes a mutable reference to the contained state and calls f with it

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl PtpInstanceStateMutex for RefCell<PtpInstanceState>

source§

fn new(state: PtpInstanceState) -> Self

source§

fn with_ref<R, F: FnOnce(&PtpInstanceState) -> R>(&self, f: F) -> R

source§

fn with_mut<R, F: FnOnce(&mut PtpInstanceState) -> R>(&self, f: F) -> R

source§

impl PtpInstanceStateMutex for RwLock<PtpInstanceState>

source§

fn new(state: PtpInstanceState) -> Self

source§

fn with_ref<R, F: FnOnce(&PtpInstanceState) -> R>(&self, f: F) -> R

source§

fn with_mut<R, F: FnOnce(&mut PtpInstanceState) -> R>(&self, f: F) -> R

Implementors§