aboutsummaryrefslogtreecommitdiff
path: root/src/flavors/at.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/flavors/at.rs')
-rw-r--r--src/flavors/at.rs23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/flavors/at.rs b/src/flavors/at.rs
index a2b1b57..4581edb 100644
--- a/src/flavors/at.rs
+++ b/src/flavors/at.rs
@@ -12,10 +12,10 @@ use crate::select::{Operation, SelectHandle, Token};
use crate::utils;
/// Result of a receive operation.
-pub type AtToken = Option<Instant>;
+pub(crate) type AtToken = Option<Instant>;
/// Channel that delivers a message at a certain moment in time
-pub struct Channel {
+pub(crate) struct Channel {
/// The instant at which the message will be delivered.
delivery_time: Instant,
@@ -26,7 +26,7 @@ pub struct Channel {
impl Channel {
/// Creates a channel that delivers a message at a certain instant in time.
#[inline]
- pub fn new_deadline(when: Instant) -> Self {
+ pub(crate) fn new_deadline(when: Instant) -> Self {
Channel {
delivery_time: when,
received: AtomicBool::new(false),
@@ -34,13 +34,13 @@ impl Channel {
}
/// Creates a channel that delivers a message after a certain duration of time.
#[inline]
- pub fn new_timeout(dur: Duration) -> Self {
+ pub(crate) fn new_timeout(dur: Duration) -> Self {
Self::new_deadline(Instant::now() + dur)
}
/// Attempts to receive a message without blocking.
#[inline]
- pub fn try_recv(&self) -> Result<Instant, TryRecvError> {
+ pub(crate) fn try_recv(&self) -> Result<Instant, TryRecvError> {
// We use relaxed ordering because this is just an optional optimistic check.
if self.received.load(Ordering::Relaxed) {
// The message has already been received.
@@ -64,7 +64,7 @@ impl Channel {
/// Receives a message from the channel.
#[inline]
- pub fn recv(&self, deadline: Option<Instant>) -> Result<Instant, RecvTimeoutError> {
+ pub(crate) fn recv(&self, deadline: Option<Instant>) -> Result<Instant, RecvTimeoutError> {
// We use relaxed ordering because this is just an optional optimistic check.
if self.received.load(Ordering::Relaxed) {
// The message has already been received.
@@ -103,13 +103,13 @@ impl Channel {
/// Reads a message from the channel.
#[inline]
- pub unsafe fn read(&self, token: &mut Token) -> Result<Instant, ()> {
+ pub(crate) unsafe fn read(&self, token: &mut Token) -> Result<Instant, ()> {
token.at.ok_or(())
}
/// Returns `true` if the channel is empty.
#[inline]
- pub fn is_empty(&self) -> bool {
+ pub(crate) fn is_empty(&self) -> bool {
// We use relaxed ordering because this is just an optional optimistic check.
if self.received.load(Ordering::Relaxed) {
return true;
@@ -127,13 +127,13 @@ impl Channel {
/// Returns `true` if the channel is full.
#[inline]
- pub fn is_full(&self) -> bool {
+ pub(crate) fn is_full(&self) -> bool {
!self.is_empty()
}
/// Returns the number of messages in the channel.
#[inline]
- pub fn len(&self) -> usize {
+ pub(crate) fn len(&self) -> usize {
if self.is_empty() {
0
} else {
@@ -142,8 +142,9 @@ impl Channel {
}
/// Returns the capacity of the channel.
+ #[allow(clippy::unnecessary_wraps)] // This is intentional.
#[inline]
- pub fn capacity(&self) -> Option<usize> {
+ pub(crate) fn capacity(&self) -> Option<usize> {
Some(1)
}
}