pub trait GuardedTarget {
    type Target;
}
Expand description

Provides a single dereferencing target type for ReadApi, WriteApi and RwApi.

Example

use read_write_api::{GuardedTarget, ReadApi, RwApi, WriteApi};

struct A(u64);

impl GuardedTarget for A {
    type Target = u64;
}

impl ReadApi for A
{
    type ReadGuard<'a>  = &'a u64
        where Self: 'a;

    fn read(&self) -> Self::ReadGuard<'_> {
        &self.0
    }
}

impl WriteApi for A
{
    type WriteGuard<'a> = &'a mut u64
        where Self: 'a;

    fn write(&mut self) -> Self::WriteGuard<'_> {
        &mut self.0
    }
}

fn accept_read_write(_: impl RwApi<Target=u64>) {}

accept_read_write(A(1))

Required Associated Types§

source

type Target

Dereference target of the read and write guards.

Implementations on Foreign Types§

source§

impl<T> GuardedTarget for &RwLock<T>

§

type Target = T

source§

impl<T> GuardedTarget for &mut RwLock<T>

§

type Target = T

source§

impl<T> GuardedTarget for RwLock<T>

§

type Target = T

Implementors§