tor-rtmock: Introduce impl_runtime_prelude
This deduplicates some imports, which would otherwise be about to become triplicated.
This commit is contained in:
parent
97e817b330
commit
492699d522
|
@ -3,15 +3,9 @@
|
|||
// TODO(nickm): This is mostly copy-paste from MockSleepRuntime. If possible,
|
||||
// we should make it so that more code is more shared.
|
||||
|
||||
use crate::net::MockNetProvider;
|
||||
use tor_rtcompat::{BlockOn, Runtime, SleepProvider, TcpProvider, TlsProvider, UdpProvider};
|
||||
use crate::util::impl_runtime_prelude::*;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use futures::task::{FutureObj, Spawn, SpawnError};
|
||||
use futures::Future;
|
||||
use std::io::Result as IoResult;
|
||||
use std::net::SocketAddr;
|
||||
use std::time::{Duration, Instant, SystemTime};
|
||||
use crate::net::MockNetProvider;
|
||||
|
||||
/// A wrapper Runtime that overrides the SleepProvider trait for the
|
||||
/// underlying runtime.
|
||||
|
|
|
@ -1,17 +1,12 @@
|
|||
//! Declare MockSleepRuntime.
|
||||
|
||||
use crate::time::MockSleepProvider;
|
||||
use tor_rtcompat::{BlockOn, Runtime, SleepProvider, TcpProvider, TlsProvider, UdpProvider};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use futures::task::{FutureObj, Spawn, SpawnError};
|
||||
use futures::Future;
|
||||
use pin_project::pin_project;
|
||||
use std::io::Result as IoResult;
|
||||
use std::net::SocketAddr;
|
||||
use std::time::{Duration, Instant, SystemTime};
|
||||
use tracing::trace;
|
||||
|
||||
use crate::time::MockSleepProvider;
|
||||
|
||||
use crate::util::impl_runtime_prelude::*;
|
||||
|
||||
/// A wrapper Runtime that overrides the SleepProvider trait for the
|
||||
/// underlying runtime.
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
|
@ -96,3 +96,23 @@ macro_rules! impl_runtime { {
|
|||
}
|
||||
}
|
||||
} }
|
||||
|
||||
/// Prelude that must be imported to use [`impl_runtime!`](impl_runtime)
|
||||
//
|
||||
// This could have been part of the expansion of `impl_runtime!`,
|
||||
// but it seems rather too exciting for a macro to import things as a side gig.
|
||||
//
|
||||
// Arguably this ought to be an internal crate::prelude instead.
|
||||
// But crate-internal preludes are controversial within the Arti team. -Diziet
|
||||
//
|
||||
// For macro visibility reasons, this must come *lexically after* the macro,
|
||||
// to allow it to refer to the macro in the doc comment.
|
||||
pub(crate) mod impl_runtime_prelude {
|
||||
pub(crate) use async_trait::async_trait;
|
||||
pub(crate) use futures::task::{FutureObj, Spawn, SpawnError};
|
||||
pub(crate) use futures::Future;
|
||||
pub(crate) use std::io::Result as IoResult;
|
||||
pub(crate) use std::net::SocketAddr;
|
||||
pub(crate) use std::time::{Duration, Instant, SystemTime};
|
||||
pub(crate) use tor_rtcompat::{BlockOn, Runtime, SleepProvider, TcpProvider, TlsProvider, UdpProvider};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue