Skip to content

Commit a4c870f

Browse files
committed
Fully encapsulate the underlying WASI types in wstd::time.
Remove the `Deref`/`DerefMut` implementations from `wstd::time::Instant` and `wstd::time::Duration`. They dereferenced to the raw WASI `monotonic_clock` types, which exposed the raw WASI types in the public API.
1 parent 35f28d2 commit a4c870f

File tree

4 files changed

+5
-33
lines changed

4 files changed

+5
-33
lines changed

src/http/client.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,17 @@ impl RequestOptions {
8787
fn to_wasi(&self) -> Result<WasiRequestOptions> {
8888
let wasi = WasiRequestOptions::new();
8989
if let Some(timeout) = self.connect_timeout {
90-
wasi.set_connect_timeout(Some(*timeout)).map_err(|()| {
90+
wasi.set_connect_timeout(Some(timeout.0)).map_err(|()| {
9191
Error::other("wasi-http implementation does not support connect timeout option")
9292
})?;
9393
}
9494
if let Some(timeout) = self.first_byte_timeout {
95-
wasi.set_first_byte_timeout(Some(*timeout)).map_err(|()| {
95+
wasi.set_first_byte_timeout(Some(timeout.0)).map_err(|()| {
9696
Error::other("wasi-http implementation does not support first byte timeout option")
9797
})?;
9898
}
9999
if let Some(timeout) = self.between_bytes_timeout {
100-
wasi.set_between_bytes_timeout(Some(*timeout))
100+
wasi.set_between_bytes_timeout(Some(timeout.0))
101101
.map_err(|()| {
102102
Error::other(
103103
"wasi-http implementation does not support between byte timeout option",

src/time/duration.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,6 @@ impl Duration {
107107
}
108108
}
109109

110-
impl std::ops::Deref for Duration {
111-
type Target = monotonic_clock::Duration;
112-
113-
fn deref(&self) -> &Self::Target {
114-
&self.0
115-
}
116-
}
117-
118-
impl std::ops::DerefMut for Duration {
119-
fn deref_mut(&mut self) -> &mut Self::Target {
120-
&mut self.0
121-
}
122-
}
123-
124110
impl From<std::time::Duration> for Duration {
125111
fn from(inner: std::time::Duration) -> Self {
126112
Self(

src/time/instant.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,6 @@ impl SubAssign<Duration> for Instant {
6767
}
6868
}
6969

70-
impl std::ops::Deref for Instant {
71-
type Target = monotonic_clock::Instant;
72-
73-
fn deref(&self) -> &Self::Target {
74-
&self.0
75-
}
76-
}
77-
78-
impl std::ops::DerefMut for Instant {
79-
fn deref_mut(&mut self) -> &mut Self::Target {
80-
&mut self.0
81-
}
82-
}
83-
8470
impl IntoFuture for Instant {
8571
type Output = Instant;
8672

src/time/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ impl Timer {
6161
Timer(None)
6262
}
6363
pub fn at(deadline: Instant) -> Timer {
64-
let pollable = Reactor::current().schedule(subscribe_instant(*deadline));
64+
let pollable = Reactor::current().schedule(subscribe_instant(deadline.0));
6565
Timer(Some(pollable))
6666
}
6767
pub fn after(duration: Duration) -> Timer {
68-
let pollable = Reactor::current().schedule(subscribe_duration(*duration));
68+
let pollable = Reactor::current().schedule(subscribe_duration(duration.0));
6969
Timer(Some(pollable))
7070
}
7171
pub fn set_after(&mut self, duration: Duration) {

0 commit comments

Comments
 (0)