use core::{
ops::Range,
pin::Pin,
task::{Context, Poll},
};
#[cfg(feature = "async")]
#[cfg_attr(feature = "doc_cfg", doc(cfg(feature = "async")))]
pub mod future; pub mod local;
#[cfg(feature = "std")]
#[cfg_attr(feature = "doc_cfg", doc(cfg(feature = "std")))]
pub mod sync;
pub unsafe trait RawIntervalRwLock {
type Index;
type TryReadLockState: Default;
type TryWriteLockState: Default;
const INIT: Self;
fn try_lock_read(
self: Pin<&Self>,
range: Range<Self::Index>,
state: Pin<&mut Self::TryReadLockState>,
) -> bool;
fn try_lock_write(
self: Pin<&Self>,
range: Range<Self::Index>,
state: Pin<&mut Self::TryWriteLockState>,
) -> bool;
fn unlock_try_read(self: Pin<&Self>, state: Pin<&mut Self::TryReadLockState>);
fn unlock_try_write(self: Pin<&Self>, state: Pin<&mut Self::TryWriteLockState>);
}
pub unsafe trait RawBlockingIntervalRwLock: RawIntervalRwLock {
type ReadLockState: Default;
type WriteLockState: Default;
type Priority;
fn lock_read(
self: Pin<&Self>,
range: Range<Self::Index>,
priority: Self::Priority,
state: Pin<&mut Self::ReadLockState>,
);
fn lock_write(
self: Pin<&Self>,
range: Range<Self::Index>,
priority: Self::Priority,
state: Pin<&mut Self::WriteLockState>,
);
fn unlock_read(self: Pin<&Self>, state: Pin<&mut Self::ReadLockState>);
fn unlock_write(self: Pin<&Self>, state: Pin<&mut Self::WriteLockState>);
}
pub unsafe trait RawAsyncIntervalRwLock: RawIntervalRwLock {
type ReadLockState: Default;
type WriteLockState: Default;
type Priority;
fn start_lock_read(
self: Pin<&Self>,
range: Range<Self::Index>,
priority: Self::Priority,
state: Pin<&mut Self::ReadLockState>,
);
fn start_lock_write(
self: Pin<&Self>,
range: Range<Self::Index>,
priority: Self::Priority,
state: Pin<&mut Self::WriteLockState>,
);
fn poll_lock_read(
self: Pin<&Self>,
state: Pin<&mut Self::ReadLockState>,
cx: &mut Context<'_>,
) -> Poll<()>;
fn poll_lock_write(
self: Pin<&Self>,
state: Pin<&mut Self::WriteLockState>,
cx: &mut Context<'_>,
) -> Poll<()>;
fn unlock_read(self: Pin<&Self>, state: Pin<&mut Self::ReadLockState>);
fn unlock_write(self: Pin<&Self>, state: Pin<&mut Self::WriteLockState>);
}