Apply nightly formatting to reorder imports and use module-level import granularity

pull/184/head
Chip Senkbeil 1 year ago
parent 5b19870b98
commit b8fecaacc0
No known key found for this signature in database
GPG Key ID: 35EF1F8EC72A4131

@ -1,15 +1,17 @@
use crate::{ use std::io;
data::{ use std::path::PathBuf;
Capabilities, ChangeKind, DirEntry, Environment, Error, Metadata, ProcessId, PtySize, use std::sync::Arc;
SearchId, SearchQuery, SystemInfo,
},
DistantMsg, DistantRequestData, DistantResponseData,
};
use async_trait::async_trait; use async_trait::async_trait;
use distant_net::common::ConnectionId; use distant_net::common::ConnectionId;
use distant_net::server::{ConnectionCtx, Reply, ServerCtx, ServerHandler}; use distant_net::server::{ConnectionCtx, Reply, ServerCtx, ServerHandler};
use log::*; use log::*;
use std::{io, path::PathBuf, sync::Arc};
use crate::data::{
Capabilities, ChangeKind, DirEntry, Environment, Error, Metadata, ProcessId, PtySize, SearchId,
SearchQuery, SystemInfo,
};
use crate::{DistantMsg, DistantRequestData, DistantResponseData};
mod local; mod local;
pub use local::LocalDistantApi; pub use local::LocalDistantApi;
@ -420,9 +422,9 @@ where
T: DistantApi<LocalData = D> + Send + Sync, T: DistantApi<LocalData = D> + Send + Sync,
D: Send + Sync, D: Send + Sync,
{ {
type LocalData = D;
type Request = DistantMsg<DistantRequestData>; type Request = DistantMsg<DistantRequestData>;
type Response = DistantMsg<DistantResponseData>; type Response = DistantMsg<DistantResponseData>;
type LocalData = D;
/// Overridden to leverage [`DistantApi`] implementation of `on_accept` /// Overridden to leverage [`DistantApi`] implementation of `on_accept`
async fn on_accept(&self, ctx: ConnectionCtx<'_, Self::LocalData>) -> io::Result<()> { async fn on_accept(&self, ctx: ConnectionCtx<'_, Self::LocalData>) -> io::Result<()> {

@ -1,19 +1,17 @@
use crate::{ use std::io;
data::{ use std::path::{Path, PathBuf};
Capabilities, ChangeKind, ChangeKindSet, DirEntry, Environment, FileType, Metadata,
ProcessId, PtySize, SearchId, SearchQuery, SystemInfo,
},
DistantApi, DistantCtx,
};
use async_trait::async_trait; use async_trait::async_trait;
use log::*; use log::*;
use std::{
io,
path::{Path, PathBuf},
};
use tokio::io::AsyncWriteExt; use tokio::io::AsyncWriteExt;
use walkdir::WalkDir; use walkdir::WalkDir;
use crate::data::{
Capabilities, ChangeKind, ChangeKindSet, DirEntry, Environment, FileType, Metadata, ProcessId,
PtySize, SearchId, SearchQuery, SystemInfo,
};
use crate::{DistantApi, DistantCtx};
mod process; mod process;
mod state; mod state;
@ -493,17 +491,20 @@ impl DistantApi for LocalDistantApi {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use std::sync::Arc;
use crate::api::ConnectionCtx; use std::time::Duration;
use crate::data::DistantResponseData;
use assert_fs::prelude::*; use assert_fs::prelude::*;
use distant_net::server::Reply; use distant_net::server::Reply;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use predicates::prelude::*; use predicates::prelude::*;
use std::{sync::Arc, time::Duration};
use test_log::test; use test_log::test;
use tokio::sync::mpsc; use tokio::sync::mpsc;
use super::*;
use crate::api::ConnectionCtx;
use crate::data::DistantResponseData;
static TEMP_SCRIPT_DIR: Lazy<assert_fs::TempDir> = static TEMP_SCRIPT_DIR: Lazy<assert_fs::TempDir> =
Lazy::new(|| assert_fs::TempDir::new().unwrap()); Lazy::new(|| assert_fs::TempDir::new().unwrap());
static SCRIPT_RUNNER: Lazy<String> = Lazy::new(|| String::from("bash")); static SCRIPT_RUNNER: Lazy<String> = Lazy::new(|| String::from("bash"));

@ -1,6 +1,10 @@
use std::future::Future;
use std::pin::Pin;
use tokio::io;
use tokio::sync::mpsc;
use crate::data::{ProcessId, PtySize}; use crate::data::{ProcessId, PtySize};
use std::{future::Future, pin::Pin};
use tokio::{io, sync::mpsc};
mod pty; mod pty;
pub use pty::*; pub use pty::*;

@ -1,20 +1,19 @@
use std::ffi::OsStr;
use std::io::{self, Read, Write};
use std::path::PathBuf;
use std::sync::{Arc, Mutex, Weak};
use log::*;
use portable_pty::{CommandBuilder, MasterPty, PtySize as PortablePtySize};
use tokio::sync::mpsc;
use tokio::task::JoinHandle;
use super::{ use super::{
wait, ExitStatus, FutureReturn, InputChannel, OutputChannel, Process, ProcessId, ProcessKiller, wait, ExitStatus, FutureReturn, InputChannel, OutputChannel, Process, ProcessId, ProcessKiller,
ProcessPty, PtySize, WaitRx, ProcessPty, PtySize, WaitRx,
}; };
use crate::{ use crate::constants::{MAX_PIPE_CHUNK_SIZE, READ_PAUSE_DURATION};
constants::{MAX_PIPE_CHUNK_SIZE, READ_PAUSE_DURATION}, use crate::data::Environment;
data::Environment,
};
use log::*;
use portable_pty::{CommandBuilder, MasterPty, PtySize as PortablePtySize};
use std::{
ffi::OsStr,
io::{self, Read, Write},
path::PathBuf,
sync::{Arc, Mutex, Weak},
};
use tokio::{sync::mpsc, task::JoinHandle};
/// Represents a process that is associated with a pty /// Represents a process that is associated with a pty
pub struct PtyProcess { pub struct PtyProcess {

@ -1,11 +1,18 @@
use std::ffi::OsStr;
use std::path::PathBuf;
use std::process::Stdio;
use log::*;
use tokio::io;
use tokio::process::Command;
use tokio::sync::mpsc;
use tokio::task::JoinHandle;
use super::{ use super::{
wait, ExitStatus, FutureReturn, InputChannel, NoProcessPty, OutputChannel, Process, ProcessId, wait, ExitStatus, FutureReturn, InputChannel, NoProcessPty, OutputChannel, Process, ProcessId,
ProcessKiller, WaitRx, ProcessKiller, WaitRx,
}; };
use crate::data::Environment; use crate::data::Environment;
use log::*;
use std::{ffi::OsStr, path::PathBuf, process::Stdio};
use tokio::{io, process::Command, sync::mpsc, task::JoinHandle};
mod tasks; mod tasks;

@ -1,10 +1,10 @@
use crate::constants::{MAX_PIPE_CHUNK_SIZE, READ_PAUSE_DURATION};
use std::io; use std::io;
use tokio::{
io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}, use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
sync::mpsc, use tokio::sync::mpsc;
task::JoinHandle, use tokio::task::JoinHandle;
};
use crate::constants::{MAX_PIPE_CHUNK_SIZE, READ_PAUSE_DURATION};
pub fn spawn_read_task<R>( pub fn spawn_read_task<R>(
reader: R, reader: R,

@ -1,4 +1,5 @@
use tokio::{io, sync::mpsc}; use tokio::io;
use tokio::sync::mpsc;
/// Exit status of a remote process /// Exit status of a remote process
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]

@ -1,10 +1,13 @@
use crate::data::{DistantResponseData, Environment, ProcessId, PtySize}; use std::collections::HashMap;
use std::io;
use std::ops::Deref;
use std::path::PathBuf;
use distant_net::server::Reply; use distant_net::server::Reply;
use std::{collections::HashMap, io, ops::Deref, path::PathBuf}; use tokio::sync::{mpsc, oneshot};
use tokio::{ use tokio::task::JoinHandle;
sync::{mpsc, oneshot},
task::JoinHandle, use crate::data::{DistantResponseData, Environment, ProcessId, PtySize};
};
mod instance; mod instance;
pub use instance::*; pub use instance::*;

@ -1,14 +1,16 @@
use crate::{ use std::future::Future;
api::local::process::{ use std::io;
InputChannel, OutputChannel, Process, ProcessKiller, ProcessPty, PtyProcess, SimpleProcess, use std::path::PathBuf;
},
data::{DistantResponseData, Environment, ProcessId, PtySize},
};
use distant_net::server::Reply; use distant_net::server::Reply;
use log::*; use log::*;
use std::{future::Future, io, path::PathBuf};
use tokio::task::JoinHandle; use tokio::task::JoinHandle;
use crate::api::local::process::{
InputChannel, OutputChannel, Process, ProcessKiller, ProcessPty, PtyProcess, SimpleProcess,
};
use crate::data::{DistantResponseData, Environment, ProcessId, PtySize};
/// Holds information related to a spawned process on the server /// Holds information related to a spawned process on the server
pub struct ProcessInstance { pub struct ProcessInstance {
pub cmd: String, pub cmd: String,

@ -1,24 +1,23 @@
use std::collections::HashMap;
use std::ops::Deref;
use std::path::Path;
use std::{cmp, io};
use distant_net::server::Reply;
use grep::matcher::Matcher;
use grep::regex::{RegexMatcher, RegexMatcherBuilder};
use grep::searcher::{BinaryDetection, Searcher, SearcherBuilder, Sink, SinkMatch};
use ignore::types::TypesBuilder;
use ignore::{DirEntry, ParallelVisitor, ParallelVisitorBuilder, WalkBuilder, WalkParallel};
use log::*;
use tokio::sync::{broadcast, mpsc, oneshot};
use tokio::task::JoinHandle;
use crate::data::{ use crate::data::{
DistantResponseData, SearchId, SearchQuery, SearchQueryContentsMatch, SearchQueryMatch, DistantResponseData, SearchId, SearchQuery, SearchQueryContentsMatch, SearchQueryMatch,
SearchQueryMatchData, SearchQueryOptions, SearchQueryPathMatch, SearchQuerySubmatch, SearchQueryMatchData, SearchQueryOptions, SearchQueryPathMatch, SearchQuerySubmatch,
SearchQueryTarget, SearchQueryTarget,
}; };
use distant_net::server::Reply;
use grep::{
matcher::Matcher,
regex::{RegexMatcher, RegexMatcherBuilder},
searcher::{BinaryDetection, Searcher, SearcherBuilder, Sink, SinkMatch},
};
use ignore::{
types::TypesBuilder, DirEntry, ParallelVisitor, ParallelVisitorBuilder, WalkBuilder,
WalkParallel,
};
use log::*;
use std::{cmp, collections::HashMap, io, ops::Deref, path::Path};
use tokio::{
sync::{broadcast, mpsc, oneshot},
task::JoinHandle,
};
const MAXIMUM_SEARCH_THREADS: usize = 12; const MAXIMUM_SEARCH_THREADS: usize = 12;
@ -808,12 +807,14 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use crate::data::{FileType, SearchQueryCondition, SearchQueryMatchData};
use assert_fs::prelude::*;
use std::path::PathBuf; use std::path::PathBuf;
use assert_fs::prelude::*;
use test_log::test; use test_log::test;
use super::*;
use crate::data::{FileType, SearchQueryCondition, SearchQueryMatchData};
fn make_path(path: &str) -> PathBuf { fn make_path(path: &str) -> PathBuf {
use std::path::MAIN_SEPARATOR; use std::path::MAIN_SEPARATOR;

@ -1,23 +1,21 @@
use crate::{constants::SERVER_WATCHER_CAPACITY, data::ChangeKind}; use std::collections::HashMap;
use std::io;
use std::ops::Deref;
use std::path::{Path, PathBuf};
use distant_net::common::ConnectionId; use distant_net::common::ConnectionId;
use log::*; use log::*;
use notify::{ use notify::{
Config as WatcherConfig, Error as WatcherError, ErrorKind as WatcherErrorKind, Config as WatcherConfig, Error as WatcherError, ErrorKind as WatcherErrorKind,
Event as WatcherEvent, PollWatcher, RecursiveMode, Watcher, Event as WatcherEvent, PollWatcher, RecursiveMode, Watcher,
}; };
use std::{ use tokio::sync::mpsc::error::TrySendError;
collections::HashMap, use tokio::sync::mpsc::{self};
io, use tokio::sync::oneshot;
ops::Deref, use tokio::task::JoinHandle;
path::{Path, PathBuf},
}; use crate::constants::SERVER_WATCHER_CAPACITY;
use tokio::{ use crate::data::ChangeKind;
sync::{
mpsc::{self, error::TrySendError},
oneshot,
},
task::JoinHandle,
};
mod path; mod path;
pub use path::*; pub use path::*;

@ -1,12 +1,11 @@
use crate::data::{Change, ChangeKind, ChangeKindSet, DistantResponseData, Error}; use std::hash::{Hash, Hasher};
use std::path::{Path, PathBuf};
use std::{fmt, io};
use distant_net::common::ConnectionId; use distant_net::common::ConnectionId;
use distant_net::server::Reply; use distant_net::server::Reply;
use std::{
fmt, use crate::data::{Change, ChangeKind, ChangeKindSet, DistantResponseData, Error};
hash::{Hash, Hasher},
io,
path::{Path, PathBuf},
};
/// Represents a path registered with a watcher that includes relevant state including /// Represents a path registered with a watcher that includes relevant state including
/// the ability to reply with /// the ability to reply with

@ -1,6 +1,11 @@
use crate::{api::DistantMsg, data::DistantResponseData}; use std::future::Future;
use std::io;
use std::pin::Pin;
use distant_net::server::Reply; use distant_net::server::Reply;
use std::{future::Future, io, pin::Pin};
use crate::api::DistantMsg;
use crate::data::DistantResponseData;
/// Wrapper around a reply that can be batch or single, converting /// Wrapper around a reply that can be batch or single, converting
/// a single data into the wrapped type /// a single data into the wrapped type

@ -1,5 +1,7 @@
use distant_net::client::Channel;
use distant_net::Client;
use crate::{DistantMsg, DistantRequestData, DistantResponseData}; use crate::{DistantMsg, DistantRequestData, DistantResponseData};
use distant_net::{client::Channel, Client};
mod ext; mod ext;
mod lsp; mod lsp;

@ -1,16 +1,20 @@
use crate::{ use std::future::Future;
client::{ use std::io;
RemoteCommand, RemoteLspCommand, RemoteLspProcess, RemoteOutput, RemoteProcess, Searcher, use std::path::PathBuf;
Watcher, use std::pin::Pin;
},
data::{ use distant_net::client::Channel;
Capabilities, ChangeKindSet, DirEntry, DistantRequestData, DistantResponseData, use distant_net::common::Request;
Environment, Error as Failure, Metadata, PtySize, SearchId, SearchQuery, SystemInfo,
}, use crate::client::{
DistantMsg, RemoteCommand, RemoteLspCommand, RemoteLspProcess, RemoteOutput, RemoteProcess, Searcher,
Watcher,
};
use crate::data::{
Capabilities, ChangeKindSet, DirEntry, DistantRequestData, DistantResponseData, Environment,
Error as Failure, Metadata, PtySize, SearchId, SearchQuery, SystemInfo,
}; };
use distant_net::{client::Channel, common::Request}; use crate::DistantMsg;
use std::{future::Future, io, path::PathBuf, pin::Pin};
pub type AsyncReturn<'a, T, E = io::Error> = pub type AsyncReturn<'a, T, E = io::Error> =
Pin<Box<dyn Future<Output = Result<T, E>> + Send + 'a>>; Pin<Box<dyn Future<Output = Result<T, E>> + Send + 'a>>;

@ -1,20 +1,17 @@
use crate::{ use std::io::{self, Cursor, Read};
client::{ use std::ops::{Deref, DerefMut};
DistantChannel, RemoteCommand, RemoteProcess, RemoteStatus, RemoteStderr, RemoteStdin, use std::path::PathBuf;
RemoteStdout,
},
data::{Environment, PtySize},
};
use futures::stream::{Stream, StreamExt}; use futures::stream::{Stream, StreamExt};
use std::{ use tokio::sync::mpsc::error::TryRecvError;
io::{self, Cursor, Read}, use tokio::sync::mpsc::{self};
ops::{Deref, DerefMut}, use tokio::task::JoinHandle;
path::PathBuf,
}; use crate::client::{
use tokio::{ DistantChannel, RemoteCommand, RemoteProcess, RemoteStatus, RemoteStderr, RemoteStdin,
sync::mpsc::{self, error::TryRecvError}, RemoteStdout,
task::JoinHandle,
}; };
use crate::data::{Environment, PtySize};
mod msg; mod msg;
pub use msg::*; pub use msg::*;
@ -397,14 +394,15 @@ fn read_lsp_messages(input: &[u8]) -> io::Result<(Option<Vec<u8>>, Vec<LspMsg>)>
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::future::Future;
use std::time::Duration;
use distant_net::common::{FramedTransport, InmemoryTransport, Request, Response};
use distant_net::Client;
use test_log::test;
use super::*; use super::*;
use crate::data::{DistantRequestData, DistantResponseData}; use crate::data::{DistantRequestData, DistantResponseData};
use distant_net::{
common::{FramedTransport, InmemoryTransport, Request, Response},
Client,
};
use std::{future::Future, time::Duration};
use test_log::test;
/// Timeout used with timeout function /// Timeout used with timeout function
const TIMEOUT: Duration = Duration::from_millis(50); const TIMEOUT: Duration = Duration::from_millis(50);

@ -1,13 +1,12 @@
use std::fmt;
use std::io::{self, BufRead};
use std::ops::{Deref, DerefMut};
use std::str::FromStr;
use std::string::FromUtf8Error;
use derive_more::{Display, Error, From}; use derive_more::{Display, Error, From};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json::{Map, Value}; use serde_json::{Map, Value};
use std::{
fmt,
io::{self, BufRead},
ops::{Deref, DerefMut},
str::FromStr,
string::FromUtf8Error,
};
/// Represents some data being communicated to/from an LSP consisting of a header and content part /// Represents some data being communicated to/from an LSP consisting of a header and content part
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
@ -61,6 +60,7 @@ impl LspMsg {
pub fn header(&self) -> &LspHeader { pub fn header(&self) -> &LspHeader {
&self.header &self.header
} }
/// Returns a mutable reference to the header part /// Returns a mutable reference to the header part
pub fn mut_header(&mut self) -> &mut LspHeader { pub fn mut_header(&mut self) -> &mut LspHeader {
&mut self.header &mut self.header
@ -395,9 +395,10 @@ impl FromStr for LspContent {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use test_log::test; use test_log::test;
use super::*;
macro_rules! make_obj { macro_rules! make_obj {
($($tail:tt)*) => { ($($tail:tt)*) => {
match serde_json::json!($($tail)*) { match serde_json::json!($($tail)*) {

@ -1,26 +1,19 @@
use crate::{ use std::path::PathBuf;
client::DistantChannel, use std::sync::Arc;
constants::CLIENT_PIPE_CAPACITY,
data::{Cmd, DistantRequestData, DistantResponseData, Environment, ProcessId, PtySize}, use distant_net::client::Mailbox;
DistantMsg, use distant_net::common::{Request, Response};
};
use distant_net::{
client::Mailbox,
common::{Request, Response},
};
use log::*; use log::*;
use std::{path::PathBuf, sync::Arc}; use tokio::io;
use tokio::{ use tokio::sync::mpsc::error::{TryRecvError, TrySendError};
io, use tokio::sync::mpsc::{self};
sync::{ use tokio::sync::RwLock;
mpsc::{ use tokio::task::JoinHandle;
self,
error::{TryRecvError, TrySendError}, use crate::client::DistantChannel;
}, use crate::constants::CLIENT_PIPE_CAPACITY;
RwLock, use crate::data::{Cmd, DistantRequestData, DistantResponseData, Environment, ProcessId, PtySize};
}, use crate::DistantMsg;
task::JoinHandle,
};
#[derive(Clone, Debug, PartialEq, Eq)] #[derive(Clone, Debug, PartialEq, Eq)]
pub struct RemoteOutput { pub struct RemoteOutput {
@ -595,18 +588,16 @@ mod errors {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use crate::{
client::DistantClient,
data::{Error, ErrorKind},
};
use distant_net::{
common::{FramedTransport, InmemoryTransport, Response},
Client,
};
use std::time::Duration; use std::time::Duration;
use distant_net::common::{FramedTransport, InmemoryTransport, Response};
use distant_net::Client;
use test_log::test; use test_log::test;
use super::*;
use crate::client::DistantClient;
use crate::data::{Error, ErrorKind};
fn make_session() -> (FramedTransport<InmemoryTransport>, DistantClient) { fn make_session() -> (FramedTransport<InmemoryTransport>, DistantClient) {
let (t1, t2) = FramedTransport::pair(100); let (t1, t2) = FramedTransport::pair(100);
(t1, Client::spawn_inmemory(t2, Default::default())) (t1, Client::spawn_inmemory(t2, Default::default()))

@ -1,13 +1,16 @@
use crate::{ use std::{fmt, io};
client::{DistantChannel, DistantChannelExt},
constants::CLIENT_SEARCHER_CAPACITY,
data::{DistantRequestData, DistantResponseData, SearchId, SearchQuery, SearchQueryMatch},
DistantMsg,
};
use distant_net::common::Request; use distant_net::common::Request;
use log::*; use log::*;
use std::{fmt, io}; use tokio::sync::mpsc;
use tokio::{sync::mpsc, task::JoinHandle}; use tokio::task::JoinHandle;
use crate::client::{DistantChannel, DistantChannelExt};
use crate::constants::CLIENT_SEARCHER_CAPACITY;
use crate::data::{
DistantRequestData, DistantResponseData, SearchId, SearchQuery, SearchQueryMatch,
};
use crate::DistantMsg;
/// Represents a searcher for files, directories, and symlinks on the filesystem /// Represents a searcher for files, directories, and symlinks on the filesystem
pub struct Searcher { pub struct Searcher {
@ -190,19 +193,20 @@ impl Searcher {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::path::PathBuf;
use std::sync::Arc;
use distant_net::common::{FramedTransport, InmemoryTransport, Response};
use distant_net::Client;
use test_log::test;
use tokio::sync::Mutex;
use super::*; use super::*;
use crate::data::{ use crate::data::{
SearchQueryCondition, SearchQueryMatchData, SearchQueryOptions, SearchQueryPathMatch, SearchQueryCondition, SearchQueryMatchData, SearchQueryOptions, SearchQueryPathMatch,
SearchQuerySubmatch, SearchQueryTarget, SearchQuerySubmatch, SearchQueryTarget,
}; };
use crate::DistantClient; use crate::DistantClient;
use distant_net::{
common::{FramedTransport, InmemoryTransport, Response},
Client,
};
use std::{path::PathBuf, sync::Arc};
use test_log::test;
use tokio::sync::Mutex;
fn make_session() -> (FramedTransport<InmemoryTransport>, DistantClient) { fn make_session() -> (FramedTransport<InmemoryTransport>, DistantClient) {
let (t1, t2) = FramedTransport::pair(100); let (t1, t2) = FramedTransport::pair(100);

@ -1,16 +1,15 @@
use crate::{ use std::path::{Path, PathBuf};
client::{DistantChannel, DistantChannelExt}, use std::{fmt, io};
constants::CLIENT_WATCHER_CAPACITY,
data::{Change, ChangeKindSet, DistantRequestData, DistantResponseData},
DistantMsg,
};
use distant_net::common::Request; use distant_net::common::Request;
use log::*; use log::*;
use std::{ use tokio::sync::mpsc;
fmt, io, use tokio::task::JoinHandle;
path::{Path, PathBuf},
}; use crate::client::{DistantChannel, DistantChannelExt};
use tokio::{sync::mpsc, task::JoinHandle}; use crate::constants::CLIENT_WATCHER_CAPACITY;
use crate::data::{Change, ChangeKindSet, DistantRequestData, DistantResponseData};
use crate::DistantMsg;
/// Represents a watcher of some path on a remote machine /// Represents a watcher of some path on a remote machine
pub struct Watcher { pub struct Watcher {
@ -181,17 +180,17 @@ impl Watcher {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use crate::data::ChangeKind;
use crate::DistantClient;
use distant_net::{
common::{FramedTransport, InmemoryTransport, Response},
Client,
};
use std::sync::Arc; use std::sync::Arc;
use distant_net::common::{FramedTransport, InmemoryTransport, Response};
use distant_net::Client;
use test_log::test; use test_log::test;
use tokio::sync::Mutex; use tokio::sync::Mutex;
use super::*;
use crate::data::ChangeKind;
use crate::DistantClient;
fn make_session() -> (FramedTransport<InmemoryTransport>, DistantClient) { fn make_session() -> (FramedTransport<InmemoryTransport>, DistantClient) {
let (t1, t2) = FramedTransport::pair(100); let (t1, t2) = FramedTransport::pair(100);
(t1, Client::spawn_inmemory(t2, Default::default())) (t1, Client::spawn_inmemory(t2, Default::default()))

@ -1,7 +1,13 @@
use crate::serde_str::{deserialize_from_str, serialize_to_str}; use std::convert::TryFrom;
use std::str::FromStr;
use std::{fmt, io};
use distant_net::common::{Destination, Host, SecretKey32}; use distant_net::common::{Destination, Host, SecretKey32};
use serde::{de::Deserializer, ser::Serializer, Deserialize, Serialize}; use serde::de::Deserializer;
use std::{convert::TryFrom, fmt, io, str::FromStr}; use serde::ser::Serializer;
use serde::{Deserialize, Serialize};
use crate::serde_str::{deserialize_from_str, serialize_to_str};
const SCHEME: &str = "distant"; const SCHEME: &str = "distant";
const SCHEME_WITH_SEP: &str = "distant://"; const SCHEME_WITH_SEP: &str = "distant://";
@ -167,11 +173,13 @@ impl TryFrom<DistantSingleKeyCredentials> for Destination {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use once_cell::sync::Lazy;
use std::net::{Ipv4Addr, Ipv6Addr}; use std::net::{Ipv4Addr, Ipv6Addr};
use once_cell::sync::Lazy;
use test_log::test; use test_log::test;
use super::*;
const HOST: &str = "testhost"; const HOST: &str = "testhost";
const PORT: u16 = 12345; const PORT: u16 = 12345;

@ -1,6 +1,8 @@
use std::io;
use std::path::PathBuf;
use derive_more::{From, IsVariant}; use derive_more::{From, IsVariant};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{io, path::PathBuf};
use strum::{AsRefStr, EnumDiscriminants, EnumIter, EnumMessage, EnumString}; use strum::{AsRefStr, EnumDiscriminants, EnumIter, EnumMessage, EnumString};
mod capabilities; mod capabilities;

@ -1,15 +1,15 @@
use super::CapabilityKind; use std::cmp::Ordering;
use std::collections::HashSet;
use std::hash::{Hash, Hasher};
use std::ops::{BitAnd, BitOr, BitXor};
use std::str::FromStr;
use derive_more::{From, Into, IntoIterator}; use derive_more::{From, Into, IntoIterator};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{
cmp::Ordering,
collections::HashSet,
hash::{Hash, Hasher},
ops::{BitAnd, BitOr, BitXor},
str::FromStr,
};
use strum::{EnumMessage, IntoEnumIterator}; use strum::{EnumMessage, IntoEnumIterator};
use super::CapabilityKind;
/// Set of supported capabilities for a server /// Set of supported capabilities for a server
#[derive(Clone, Debug, From, Into, PartialEq, Eq, IntoIterator, Serialize, Deserialize)] #[derive(Clone, Debug, From, Into, PartialEq, Eq, IntoIterator, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]

@ -1,15 +1,15 @@
use std::collections::HashSet;
use std::fmt;
use std::hash::{Hash, Hasher};
use std::iter::FromIterator;
use std::ops::{BitOr, Sub};
use std::path::PathBuf;
use std::str::FromStr;
use derive_more::{Deref, DerefMut, IntoIterator}; use derive_more::{Deref, DerefMut, IntoIterator};
use notify::{event::Event as NotifyEvent, EventKind as NotifyEventKind}; use notify::event::Event as NotifyEvent;
use notify::EventKind as NotifyEventKind;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{
collections::HashSet,
fmt,
hash::{Hash, Hasher},
iter::FromIterator,
ops::{BitOr, Sub},
path::PathBuf,
str::FromStr,
};
use strum::{EnumString, EnumVariantNames, VariantNames}; use strum::{EnumString, EnumVariantNames, VariantNames};
/// Change to one or more paths on the filesystem /// Change to one or more paths on the filesystem

@ -1,6 +1,7 @@
use std::ops::{Deref, DerefMut};
use derive_more::{Display, From, Into}; use derive_more::{Display, From, Into};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::ops::{Deref, DerefMut};
/// Represents some command with arguments to execute /// Represents some command with arguments to execute
#[derive(Clone, Debug, Display, From, Into, Hash, PartialEq, Eq, Serialize, Deserialize)] #[derive(Clone, Debug, Display, From, Into, Hash, PartialEq, Eq, Serialize, Deserialize)]

@ -1,7 +1,8 @@
use std::io;
use derive_more::Display; use derive_more::Display;
use notify::ErrorKind as NotifyErrorKind; use notify::ErrorKind as NotifyErrorKind;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::io;
/// General purpose error type that can be sent across the wire /// General purpose error type that can be sent across the wire
#[derive(Clone, Debug, Display, PartialEq, Eq, Serialize, Deserialize)] #[derive(Clone, Debug, Display, PartialEq, Eq, Serialize, Deserialize)]

@ -1,6 +1,8 @@
use std::fs::FileType as StdFileType;
use std::path::PathBuf;
use derive_more::IsVariant; use derive_more::IsVariant;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{fs::FileType as StdFileType, path::PathBuf};
use strum::AsRefStr; use strum::AsRefStr;
/// Represents information about a single entry within a directory /// Represents information about a single entry within a directory

@ -1,11 +1,11 @@
use super::{deserialize_u128_option, serialize_u128_option, FileType}; use std::io;
use std::path::{Path, PathBuf};
use std::time::SystemTime;
use bitflags::bitflags; use bitflags::bitflags;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{
io, use super::{deserialize_u128_option, serialize_u128_option, FileType};
path::{Path, PathBuf},
time::SystemTime,
};
/// Represents metadata about some path on a remote machine /// Represents metadata about some path on a remote machine
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]

@ -1,7 +1,10 @@
use std::fmt;
use std::num::ParseIntError;
use std::str::FromStr;
use derive_more::{Display, Error}; use derive_more::{Display, Error};
use portable_pty::PtySize as PortablePtySize; use portable_pty::PtySize as PortablePtySize;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{fmt, num::ParseIntError, str::FromStr};
/// Represents the size associated with a remote PTY /// Represents the size associated with a remote PTY
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]

@ -1,6 +1,11 @@
use super::FileType; use std::borrow::Cow;
use std::collections::HashSet;
use std::path::PathBuf;
use std::str::FromStr;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{borrow::Cow, collections::HashSet, path::PathBuf, str::FromStr};
use super::FileType;
/// Id associated with a search /// Id associated with a search
pub type SearchId = u32; pub type SearchId = u32;
@ -380,9 +385,10 @@ mod tests {
use super::*; use super::*;
mod search_query_condition { mod search_query_condition {
use super::*;
use test_log::test; use test_log::test;
use super::*;
#[test] #[test]
fn to_regex_string_should_convert_to_appropriate_regex_and_escape_as_needed() { fn to_regex_string_should_convert_to_appropriate_regex_and_escape_as_needed() {
assert_eq!( assert_eq!(

@ -1,5 +1,7 @@
use std::env;
use std::path::PathBuf;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{env, path::PathBuf};
/// Represents information about a system /// Represents information about a system
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]

@ -1,8 +1,9 @@
use serde::{ use std::fmt;
de::{Deserializer, Error as SerdeError, Visitor}, use std::marker::PhantomData;
ser::Serializer, use std::str::FromStr;
};
use std::{fmt, marker::PhantomData, str::FromStr}; use serde::de::{Deserializer, Error as SerdeError, Visitor};
use serde::ser::Serializer;
/// From https://docs.rs/serde_with/1.14.0/src/serde_with/rust.rs.html#90-118 /// From https://docs.rs/serde_with/1.14.0/src/serde_with/rust.rs.html#90-118
pub fn deserialize_from_str<'de, D, T>(deserializer: D) -> Result<T, D::Error> pub fn deserialize_from_str<'de, D, T>(deserializer: D) -> Result<T, D::Error>

@ -1,9 +1,10 @@
use crate::stress::fixtures::*;
use assert_fs::prelude::*; use assert_fs::prelude::*;
use distant_core::DistantChannelExt; use distant_core::DistantChannelExt;
use rstest::*; use rstest::*;
use test_log::test; use test_log::test;
use crate::stress::fixtures::*;
// 64KB is maximum TCP packet size // 64KB is maximum TCP packet size
const MAX_TCP_PACKET_BYTES: usize = 65535; const MAX_TCP_PACKET_BYTES: usize = 65535;

@ -1,9 +1,11 @@
use crate::stress::fixtures::*;
use assert_fs::prelude::*; use assert_fs::prelude::*;
use distant_core::{data::ChangeKindSet, DistantChannelExt}; use distant_core::data::ChangeKindSet;
use distant_core::DistantChannelExt;
use rstest::*; use rstest::*;
use test_log::test; use test_log::test;
use crate::stress::fixtures::*;
const MAX_FILES: usize = 500; const MAX_FILES: usize = 500;
#[rstest] #[rstest]

@ -1,11 +1,12 @@
use std::net::SocketAddr;
use std::time::Duration;
use distant_core::net::client::{Client, TcpConnector}; use distant_core::net::client::{Client, TcpConnector};
use distant_core::net::common::authentication::{DummyAuthHandler, Verifier}; use distant_core::net::common::authentication::{DummyAuthHandler, Verifier};
use distant_core::net::common::PortRange; use distant_core::net::common::PortRange;
use distant_core::net::server::Server; use distant_core::net::server::Server;
use distant_core::{DistantApiServerHandler, DistantClient, LocalDistantApi}; use distant_core::{DistantApiServerHandler, DistantClient, LocalDistantApi};
use rstest::*; use rstest::*;
use std::net::SocketAddr;
use std::time::Duration;
use tokio::sync::mpsc; use tokio::sync::mpsc;
pub struct DistantClientCtx { pub struct DistantClientCtx {

@ -1,19 +1,18 @@
use std::ops::{Deref, DerefMut};
use std::sync::Arc;
use std::time::{Duration, Instant};
use std::{fmt, io};
use log::*;
use serde::de::DeserializeOwned;
use serde::Serialize;
use tokio::sync::{mpsc, oneshot, watch};
use tokio::task::JoinHandle;
use crate::common::{ use crate::common::{
Connection, FramedTransport, HeapSecretKey, InmemoryTransport, Interest, Reconnectable, Connection, FramedTransport, HeapSecretKey, InmemoryTransport, Interest, Reconnectable,
Transport, UntypedRequest, UntypedResponse, Transport, UntypedRequest, UntypedResponse,
}; };
use log::*;
use serde::{de::DeserializeOwned, Serialize};
use std::{
fmt, io,
ops::{Deref, DerefMut},
sync::Arc,
time::{Duration, Instant},
};
use tokio::{
sync::{mpsc, oneshot, watch},
task::JoinHandle,
};
mod builder; mod builder;
pub use builder::*; pub use builder::*;
@ -644,8 +643,9 @@ mod tests {
use crate::common::{Ready, Request, Response, TestTransport}; use crate::common::{Ready, Request, Response, TestTransport};
mod typed { mod typed {
use super::*;
use test_log::test; use test_log::test;
use super::*;
type TestClient = Client<u8, u8>; type TestClient = Client<u8, u8>;
fn spawn_test_client<T>( fn spawn_test_client<T>(
@ -962,8 +962,9 @@ mod tests {
} }
mod untyped { mod untyped {
use super::*;
use test_log::test; use test_log::test;
use super::*;
type TestClient = UntypedClient; type TestClient = UntypedClient;
/// Creates a new test transport whose operations do not panic, but do nothing. /// Creates a new test transport whose operations do not panic, but do nothing.

@ -10,14 +10,17 @@ pub use unix::*;
#[cfg(windows)] #[cfg(windows)]
mod windows; mod windows;
use std::time::Duration;
use std::{convert, io};
use async_trait::async_trait;
#[cfg(windows)] #[cfg(windows)]
pub use windows::*; pub use windows::*;
use super::ClientConfig; use super::ClientConfig;
use crate::client::{Client, UntypedClient}; use crate::client::{Client, UntypedClient};
use crate::common::{authentication::AuthHandler, Connection, Transport}; use crate::common::authentication::AuthHandler;
use async_trait::async_trait; use crate::common::{Connection, Transport};
use std::{convert, io, time::Duration};
/// Interface that performs the connection to produce a [`Transport`] for use by the [`Client`]. /// Interface that performs the connection to produce a [`Transport`] for use by the [`Client`].
#[async_trait] #[async_trait]

@ -1,9 +1,11 @@
use super::Connector;
use crate::common::TcpTransport;
use async_trait::async_trait;
use std::io; use std::io;
use async_trait::async_trait;
use tokio::net::ToSocketAddrs; use tokio::net::ToSocketAddrs;
use super::Connector;
use crate::common::TcpTransport;
/// Implementation of [`Connector`] to support connecting via TCP. /// Implementation of [`Connector`] to support connecting via TCP.
pub struct TcpConnector<T> { pub struct TcpConnector<T> {
addr: T, addr: T,

@ -1,7 +1,10 @@
use std::io;
use std::path::PathBuf;
use async_trait::async_trait;
use super::Connector; use super::Connector;
use crate::common::UnixSocketTransport; use crate::common::UnixSocketTransport;
use async_trait::async_trait;
use std::{io, path::PathBuf};
/// Implementation of [`Connector`] to support connecting via a Unix socket. /// Implementation of [`Connector`] to support connecting via a Unix socket.
pub struct UnixSocketConnector { pub struct UnixSocketConnector {

@ -1,9 +1,11 @@
use super::Connector;
use crate::common::WindowsPipeTransport;
use async_trait::async_trait;
use std::ffi::OsString; use std::ffi::OsString;
use std::io; use std::io;
use async_trait::async_trait;
use super::Connector;
use crate::common::WindowsPipeTransport;
/// Implementation of [`Connector`] to support connecting via a Windows named pipe. /// Implementation of [`Connector`] to support connecting via a Windows named pipe.
pub struct WindowsPipeConnector { pub struct WindowsPipeConnector {
addr: OsString, addr: OsString,

@ -1,8 +1,14 @@
use crate::common::{Request, Response, UntypedRequest, UntypedResponse}; use std::marker::PhantomData;
use std::sync::Weak;
use std::{convert, fmt, io};
use log::*; use log::*;
use serde::{de::DeserializeOwned, Serialize}; use serde::de::DeserializeOwned;
use std::{convert, fmt, io, marker::PhantomData, sync::Weak}; use serde::Serialize;
use tokio::{sync::mpsc, time::Duration}; use tokio::sync::mpsc;
use tokio::time::Duration;
use crate::common::{Request, Response, UntypedRequest, UntypedResponse};
mod mailbox; mod mailbox;
pub use mailbox::*; pub use mailbox::*;
@ -336,11 +342,13 @@ mod tests {
use super::*; use super::*;
mod typed { mod typed {
use super::*;
use std::sync::Arc; use std::sync::Arc;
use std::time::Duration; use std::time::Duration;
use test_log::test; use test_log::test;
use super::*;
type TestChannel = Channel<u8, u8>; type TestChannel = Channel<u8, u8>;
type Setup = ( type Setup = (
TestChannel, TestChannel,
@ -446,11 +454,13 @@ mod tests {
} }
mod untyped { mod untyped {
use super::*;
use std::sync::Arc; use std::sync::Arc;
use std::time::Duration; use std::time::Duration;
use test_log::test; use test_log::test;
use super::*;
type TestChannel = UntypedChannel; type TestChannel = UntypedChannel;
type Setup = ( type Setup = (
TestChannel, TestChannel,

@ -1,15 +1,12 @@
use crate::common::{Id, Response, UntypedResponse}; use std::collections::HashMap;
use std::sync::{Arc, Weak};
use std::time::Duration;
use async_trait::async_trait; use async_trait::async_trait;
use std::{ use tokio::sync::{mpsc, Mutex, RwLock};
collections::HashMap, use tokio::{io, time};
sync::{Arc, Weak},
time::Duration, use crate::common::{Id, Response, UntypedResponse};
};
use tokio::{
io,
sync::{mpsc, Mutex, RwLock},
time,
};
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct PostOffice<T> { pub struct PostOffice<T> {

@ -1,6 +1,7 @@
use super::ReconnectStrategy;
use std::time::Duration; use std::time::Duration;
use super::ReconnectStrategy;
const DEFAULT_SILENCE_DURATION: Duration = Duration::from_secs(20); const DEFAULT_SILENCE_DURATION: Duration = Duration::from_secs(20);
const MAXIMUM_SILENCE_DURATION: Duration = Duration::from_millis(68719476734); const MAXIMUM_SILENCE_DURATION: Duration = Duration::from_millis(68719476734);

@ -1,11 +1,13 @@
use super::Reconnectable;
use log::*;
use std::io; use std::io;
use std::time::Duration; use std::time::Duration;
use log::*;
use strum::Display; use strum::Display;
use tokio::sync::watch; use tokio::sync::watch;
use tokio::task::JoinHandle; use tokio::task::JoinHandle;
use super::Reconnectable;
/// Represents a watcher over a [`ConnectionState`]. /// Represents a watcher over a [`ConnectionState`].
#[derive(Clone)] #[derive(Clone)]
pub struct ConnectionWatcher(pub(super) watch::Receiver<ConnectionState>); pub struct ConnectionWatcher(pub(super) watch::Receiver<ConnectionState>);

@ -1,6 +1,7 @@
use std::io;
use async_trait::async_trait; use async_trait::async_trait;
use dyn_clone::DynClone; use dyn_clone::DynClone;
use std::io;
use tokio::sync::{mpsc, oneshot}; use tokio::sync::{mpsc, oneshot};
/// Interface representing functionality to shut down an active client. /// Interface representing functionality to shut down an active client.

@ -1,8 +1,11 @@
use super::{msg::*, AuthHandler}; use std::io;
use crate::common::{utils, FramedTransport, Transport};
use async_trait::async_trait; use async_trait::async_trait;
use log::*; use log::*;
use std::io;
use super::msg::*;
use super::AuthHandler;
use crate::common::{utils, FramedTransport, Transport};
/// Represents an interface for authenticating with a server. /// Represents an interface for authenticating with a server.
#[async_trait] #[async_trait]
@ -200,11 +203,12 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use crate::common::authentication::AuthMethodHandler;
use test_log::test; use test_log::test;
use tokio::sync::mpsc; use tokio::sync::mpsc;
use super::*;
use crate::common::authentication::AuthMethodHandler;
#[async_trait] #[async_trait]
trait TestAuthHandler { trait TestAuthHandler {
async fn on_initialization( async fn on_initialization(

@ -1,9 +1,11 @@
use std::collections::HashMap;
use std::io;
use async_trait::async_trait;
use super::msg::*; use super::msg::*;
use crate::common::authentication::Authenticator; use crate::common::authentication::Authenticator;
use crate::common::HeapSecretKey; use crate::common::HeapSecretKey;
use async_trait::async_trait;
use std::collections::HashMap;
use std::io;
mod methods; mod methods;
pub use methods::*; pub use methods::*;

@ -1,8 +1,10 @@
use std::io;
use async_trait::async_trait;
use super::{ use super::{
Challenge, ChallengeResponse, Error, Info, Verification, VerificationKind, VerificationResponse, Challenge, ChallengeResponse, Error, Info, Verification, VerificationKind, VerificationResponse,
}; };
use async_trait::async_trait;
use std::io;
/// Interface for a handler of authentication requests for a specific authentication method. /// Interface for a handler of authentication requests for a specific authentication method.
#[async_trait] #[async_trait]

@ -1,10 +1,12 @@
use std::io;
use async_trait::async_trait;
use log::*;
use super::{ use super::{
AuthMethodHandler, Challenge, ChallengeResponse, Error, Info, Verification, VerificationKind, AuthMethodHandler, Challenge, ChallengeResponse, Error, Info, Verification, VerificationKind,
VerificationResponse, VerificationResponse,
}; };
use async_trait::async_trait;
use log::*;
use std::io;
/// Blocking implementation of [`AuthMethodHandler`] that uses prompts to communicate challenge & /// Blocking implementation of [`AuthMethodHandler`] that uses prompts to communicate challenge &
/// verification requests, receiving responses to relay back. /// verification requests, receiving responses to relay back.

@ -1,11 +1,13 @@
use std::io;
use async_trait::async_trait;
use log::*;
use super::{ use super::{
AuthMethodHandler, Challenge, ChallengeResponse, Error, Info, Verification, AuthMethodHandler, Challenge, ChallengeResponse, Error, Info, Verification,
VerificationResponse, VerificationResponse,
}; };
use crate::common::HeapSecretKey; use crate::common::HeapSecretKey;
use async_trait::async_trait;
use log::*;
use std::io;
/// Implementation of [`AuthMethodHandler`] that answers challenge requests using a static /// Implementation of [`AuthMethodHandler`] that answers challenge requests using a static
/// [`HeapSecretKey`]. All other portions of method authentication are handled by another /// [`HeapSecretKey`]. All other portions of method authentication are handled by another
@ -98,9 +100,10 @@ impl AuthMethodHandler for StaticKeyAuthMethodHandler {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use test_log::test;
use super::*; use super::*;
use crate::common::authentication::msg::{ErrorKind, Question, VerificationKind}; use crate::common::authentication::msg::{ErrorKind, Question, VerificationKind};
use test_log::test;
#[test(tokio::test)] #[test(tokio::test)]
async fn on_challenge_should_fail_if_non_key_question_received() { async fn on_challenge_should_fail_if_non_key_question_received() {

@ -1,8 +1,10 @@
use crate::common::HeapSecretKey;
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::Arc; use std::sync::Arc;
use tokio::sync::RwLock; use tokio::sync::RwLock;
use crate::common::HeapSecretKey;
/// Represents the result of a request to the database. /// Represents the result of a request to the database.
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum KeychainResult<T> { pub enum KeychainResult<T> {

@ -1,9 +1,13 @@
use super::{super::HeapSecretKey, msg::*, Authenticator};
use async_trait::async_trait;
use log::*;
use std::collections::HashMap; use std::collections::HashMap;
use std::io; use std::io;
use async_trait::async_trait;
use log::*;
use super::super::HeapSecretKey;
use super::msg::*;
use super::Authenticator;
mod none; mod none;
mod static_key; mod static_key;
@ -113,9 +117,10 @@ pub trait AuthenticationMethod: Send + Sync {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use test_log::test;
use super::*; use super::*;
use crate::common::FramedTransport; use crate::common::FramedTransport;
use test_log::test;
struct SuccessAuthenticationMethod; struct SuccessAuthenticationMethod;

@ -1,7 +1,9 @@
use super::{AuthenticationMethod, Authenticator};
use async_trait::async_trait;
use std::io; use std::io;
use async_trait::async_trait;
use super::{AuthenticationMethod, Authenticator};
/// Authenticaton method for a static secret key /// Authenticaton method for a static secret key
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct NoneAuthenticationMethod; pub struct NoneAuthenticationMethod;

@ -1,7 +1,9 @@
use std::io;
use async_trait::async_trait;
use super::{AuthenticationMethod, Authenticator, Challenge, Error, Question}; use super::{AuthenticationMethod, Authenticator, Challenge, Error, Question};
use crate::common::HeapSecretKey; use crate::common::HeapSecretKey;
use async_trait::async_trait;
use std::io;
/// Authenticaton method for a static secret key /// Authenticaton method for a static secret key
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
@ -53,13 +55,12 @@ impl AuthenticationMethod for StaticKeyAuthenticationMethod {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use crate::common::{
authentication::msg::{AuthenticationResponse, ChallengeResponse},
FramedTransport,
};
use test_log::test; use test_log::test;
use super::*;
use crate::common::authentication::msg::{AuthenticationResponse, ChallengeResponse};
use crate::common::FramedTransport;
#[test(tokio::test)] #[test(tokio::test)]
async fn authenticate_should_fail_if_key_challenge_fails() { async fn authenticate_should_fail_if_key_challenge_fails() {
let method = StaticKeyAuthenticationMethod::new(b"".to_vec()); let method = StaticKeyAuthenticationMethod::new(b"".to_vec());

@ -1,6 +1,7 @@
use std::collections::HashMap;
use derive_more::{Display, Error, From}; use derive_more::{Display, Error, From};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::HashMap;
/// Represents messages from an authenticator that act as initiators such as providing /// Represents messages from an authenticator that act as initiators such as providing
/// a challenge, verifying information, presenting information, or highlighting an error /// a challenge, verifying information, presenting information, or highlighting an error

@ -1,16 +1,15 @@
use super::{ use std::io;
authentication::{AuthHandler, Authenticate, Keychain, KeychainResult, Verifier}, use std::ops::{Deref, DerefMut};
Backup, FramedTransport, HeapSecretKey, Reconnectable, Transport,
};
use async_trait::async_trait; use async_trait::async_trait;
use log::*; use log::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::io;
use std::ops::{Deref, DerefMut};
use tokio::sync::oneshot; use tokio::sync::oneshot;
use super::authentication::{AuthHandler, Authenticate, Keychain, KeychainResult, Verifier};
#[cfg(test)] #[cfg(test)]
use super::InmemoryTransport; use super::InmemoryTransport;
use super::{Backup, FramedTransport, HeapSecretKey, Reconnectable, Transport};
/// Id of the connection /// Id of the connection
pub type ConnectionId = u32; pub type ConnectionId = u32;
@ -454,14 +453,15 @@ impl<T: Transport> Connection<T> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use crate::common::{
authentication::{msg::Challenge, Authenticator, DummyAuthHandler},
Frame,
};
use std::sync::Arc; use std::sync::Arc;
use test_log::test; use test_log::test;
use super::*;
use crate::common::authentication::msg::Challenge;
use crate::common::authentication::{Authenticator, DummyAuthHandler};
use crate::common::Frame;
#[test(tokio::test)] #[test(tokio::test)]
async fn client_should_fail_if_codec_handshake_fails() { async fn client_should_fail_if_codec_handshake_fails() {
let (mut t1, t2) = FramedTransport::pair(100); let (mut t1, t2) = FramedTransport::pair(100);

@ -1,6 +1,12 @@
use std::fmt;
use std::hash::Hash;
use std::str::FromStr;
use serde::de::Deserializer;
use serde::ser::Serializer;
use serde::{Deserialize, Serialize};
use super::utils::{deserialize_from_str, serialize_to_str}; use super::utils::{deserialize_from_str, serialize_to_str};
use serde::{de::Deserializer, ser::Serializer, Deserialize, Serialize};
use std::{fmt, hash::Hash, str::FromStr};
mod host; mod host;
mod parser; mod parser;

@ -1,11 +1,13 @@
use super::{deserialize_from_str, serialize_to_str}; use std::fmt;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
use std::str::FromStr;
use derive_more::{Display, Error, From}; use derive_more::{Display, Error, From};
use serde::{de::Deserializer, ser::Serializer, Deserialize, Serialize}; use serde::de::Deserializer;
use std::{ use serde::ser::Serializer;
fmt, use serde::{Deserialize, Serialize};
net::{IpAddr, Ipv4Addr, Ipv6Addr},
str::FromStr, use super::{deserialize_from_str, serialize_to_str};
};
/// Represents the host of a destination /// Represents the host of a destination
#[derive(Clone, Debug, From, Display, Hash, PartialEq, Eq)] #[derive(Clone, Debug, From, Display, Hash, PartialEq, Eq)]

@ -342,9 +342,10 @@ mod tests {
} }
mod parse_host { mod parse_host {
use super::*;
use std::net::{Ipv4Addr, Ipv6Addr}; use std::net::{Ipv4Addr, Ipv6Addr};
use super::*;
#[test] #[test]
fn should_fail_if_domain_name_is_invalid() { fn should_fail_if_domain_name_is_invalid() {
let _ = parse_host("").unwrap_err(); let _ = parse_host("").unwrap_err();

@ -1,6 +1,7 @@
use async_trait::async_trait;
use std::io; use std::io;
use async_trait::async_trait;
mod mapped; mod mapped;
pub use mapped::*; pub use mapped::*;

@ -1,7 +1,9 @@
use super::Listener;
use async_trait::async_trait;
use std::io; use std::io;
use async_trait::async_trait;
use super::Listener;
/// Represents a [`Listener`] that wraps a different [`Listener`], /// Represents a [`Listener`] that wraps a different [`Listener`],
/// mapping the received connection to something else using the map function /// mapping the received connection to something else using the map function
pub struct MappedListener<L, F, T, U> pub struct MappedListener<L, F, T, U>

@ -1,9 +1,11 @@
use super::Listener; use std::io;
use async_trait::async_trait; use async_trait::async_trait;
use derive_more::From; use derive_more::From;
use std::io;
use tokio::sync::mpsc; use tokio::sync::mpsc;
use super::Listener;
/// Represents a [`Listener`] that uses an [`mpsc::Receiver`] to /// Represents a [`Listener`] that uses an [`mpsc::Receiver`] to
/// accept new connections /// accept new connections
#[derive(From)] #[derive(From)]

@ -1,9 +1,11 @@
use super::Listener; use std::io;
use async_trait::async_trait; use async_trait::async_trait;
use derive_more::From; use derive_more::From;
use std::io;
use tokio::sync::oneshot; use tokio::sync::oneshot;
use super::Listener;
/// Represents a [`Listener`] that only has a single connection /// Represents a [`Listener`] that only has a single connection
#[derive(From)] #[derive(From)]
pub struct OneshotListener<T: Send> { pub struct OneshotListener<T: Send> {
@ -47,10 +49,11 @@ impl<T: Send> Listener for OneshotListener<T> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use test_log::test; use test_log::test;
use tokio::task::JoinHandle; use tokio::task::JoinHandle;
use super::*;
#[test(tokio::test)] #[test(tokio::test)]
async fn from_value_should_return_value_on_first_call_to_accept() { async fn from_value_should_return_value_on_first_call_to_accept() {
let mut listener = OneshotListener::from_value("hello world"); let mut listener = OneshotListener::from_value("hello world");

@ -1,9 +1,12 @@
use super::Listener; use std::net::IpAddr;
use crate::common::{PortRange, TcpTransport}; use std::{fmt, io};
use async_trait::async_trait; use async_trait::async_trait;
use std::{fmt, io, net::IpAddr};
use tokio::net::TcpListener as TokioTcpListener; use tokio::net::TcpListener as TokioTcpListener;
use super::Listener;
use crate::common::{PortRange, TcpTransport};
/// Represents a [`Listener`] for incoming connections over TCP /// Represents a [`Listener`] for incoming connections over TCP
pub struct TcpListener { pub struct TcpListener {
addr: IpAddr, addr: IpAddr,
@ -64,11 +67,14 @@ impl Listener for TcpListener {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use crate::common::TransportExt;
use std::net::{Ipv6Addr, SocketAddr}; use std::net::{Ipv6Addr, SocketAddr};
use test_log::test; use test_log::test;
use tokio::{sync::oneshot, task::JoinHandle}; use tokio::sync::oneshot;
use tokio::task::JoinHandle;
use super::*;
use crate::common::TransportExt;
#[test(tokio::test)] #[test(tokio::test)]
async fn should_fail_to_bind_if_port_already_bound() { async fn should_fail_to_bind_if_port_already_bound() {

@ -1,13 +1,13 @@
use super::Listener; use std::os::unix::fs::PermissionsExt;
use crate::common::UnixSocketTransport; use std::path::{Path, PathBuf};
use std::{fmt, io};
use async_trait::async_trait; use async_trait::async_trait;
use std::{
fmt, io,
os::unix::fs::PermissionsExt,
path::{Path, PathBuf},
};
use tokio::net::{UnixListener, UnixStream}; use tokio::net::{UnixListener, UnixStream};
use super::Listener;
use crate::common::UnixSocketTransport;
/// Represents a [`Listener`] for incoming connections over a Unix socket /// Represents a [`Listener`] for incoming connections over a Unix socket
pub struct UnixSocketListener { pub struct UnixSocketListener {
path: PathBuf, path: PathBuf,
@ -94,11 +94,13 @@ impl Listener for UnixSocketListener {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use crate::common::TransportExt;
use tempfile::NamedTempFile; use tempfile::NamedTempFile;
use test_log::test; use test_log::test;
use tokio::{sync::oneshot, task::JoinHandle}; use tokio::sync::oneshot;
use tokio::task::JoinHandle;
use super::*;
use crate::common::TransportExt;
#[test(tokio::test)] #[test(tokio::test)]
async fn should_succeed_to_bind_if_file_exists_at_path_but_nothing_listening() { async fn should_succeed_to_bind_if_file_exists_at_path_but_nothing_listening() {

@ -1,12 +1,12 @@
use super::Listener; use std::ffi::{OsStr, OsString};
use crate::common::{NamedPipe, WindowsPipeTransport}; use std::{fmt, io, mem};
use async_trait::async_trait; use async_trait::async_trait;
use std::{
ffi::{OsStr, OsString},
fmt, io, mem,
};
use tokio::net::windows::named_pipe::{NamedPipeServer, ServerOptions}; use tokio::net::windows::named_pipe::{NamedPipeServer, ServerOptions};
use super::Listener;
use crate::common::{NamedPipe, WindowsPipeTransport};
/// Represents a [`Listener`] for incoming connections over a named windows pipe /// Represents a [`Listener`] for incoming connections over a named windows pipe
pub struct WindowsPipeListener { pub struct WindowsPipeListener {
addr: OsString, addr: OsString,
@ -66,10 +66,12 @@ impl Listener for WindowsPipeListener {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use test_log::test;
use tokio::sync::oneshot;
use tokio::task::JoinHandle;
use super::*; use super::*;
use crate::common::TransportExt; use crate::common::TransportExt;
use test_log::test;
use tokio::{sync::oneshot, task::JoinHandle};
#[test(tokio::test)] #[test(tokio::test)]
async fn should_fail_to_bind_if_pipe_already_bound() { async fn should_fail_to_bind_if_pipe_already_bound() {

@ -1,13 +1,15 @@
use crate::common::utils::{deserialize_from_str, serialize_to_str}; use std::collections::hash_map::Entry;
use std::collections::HashMap;
use std::fmt;
use std::ops::{Deref, DerefMut};
use std::str::FromStr;
use derive_more::{Display, Error, From, IntoIterator}; use derive_more::{Display, Error, From, IntoIterator};
use serde::{de::Deserializer, ser::Serializer, Deserialize, Serialize}; use serde::de::Deserializer;
use std::{ use serde::ser::Serializer;
collections::hash_map::Entry, use serde::{Deserialize, Serialize};
collections::HashMap,
fmt, use crate::common::utils::{deserialize_from_str, serialize_to_str};
ops::{Deref, DerefMut},
str::FromStr,
};
/// Contains map information for connections and other use cases /// Contains map information for connections and other use cases
#[derive(Clone, Debug, From, IntoIterator, PartialEq, Eq)] #[derive(Clone, Debug, From, IntoIterator, PartialEq, Eq)]

@ -1,8 +1,12 @@
use std::borrow::Cow;
use std::{io, str};
use derive_more::{Display, Error};
use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};
use super::{parse_msg_pack_str, write_str_msg_pack, Id}; use super::{parse_msg_pack_str, write_str_msg_pack, Id};
use crate::common::utils; use crate::common::utils;
use derive_more::{Display, Error};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use std::{borrow::Cow, io, str};
/// Represents a request to send /// Represents a request to send
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
@ -195,9 +199,10 @@ impl<'a> UntypedRequest<'a> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use test_log::test; use test_log::test;
use super::*;
const TRUE_BYTE: u8 = 0xc3; const TRUE_BYTE: u8 = 0xc3;
const NEVER_USED_BYTE: u8 = 0xc1; const NEVER_USED_BYTE: u8 = 0xc1;

@ -1,8 +1,12 @@
use std::borrow::Cow;
use std::io;
use derive_more::{Display, Error};
use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};
use super::{parse_msg_pack_str, write_str_msg_pack, Id}; use super::{parse_msg_pack_str, write_str_msg_pack, Id};
use crate::common::utils; use crate::common::utils;
use derive_more::{Display, Error};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use std::{borrow::Cow, io};
/// Represents a response received related to some response /// Represents a response received related to some response
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
@ -233,9 +237,10 @@ impl<'a> UntypedResponse<'a> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use test_log::test; use test_log::test;
use super::*;
const TRUE_BYTE: u8 = 0xc3; const TRUE_BYTE: u8 = 0xc3;
const NEVER_USED_BYTE: u8 = 0xc1; const NEVER_USED_BYTE: u8 = 0xc1;

@ -1,11 +1,10 @@
use std::fmt;
use std::net::{IpAddr, SocketAddr};
use std::ops::RangeInclusive;
use std::str::FromStr;
use derive_more::Display; use derive_more::Display;
use serde::{de, Deserialize, Serialize}; use serde::{de, Deserialize, Serialize};
use std::{
fmt,
net::{IpAddr, SocketAddr},
ops::RangeInclusive,
str::FromStr,
};
/// Represents some range of ports /// Represents some range of ports
#[derive(Copy, Clone, Debug, Display, PartialEq, Eq)] #[derive(Copy, Clone, Debug, Display, PartialEq, Eq)]
@ -71,8 +70,8 @@ impl From<RangeInclusive<u16>> for PortRange {
} }
impl<'a> IntoIterator for &'a PortRange { impl<'a> IntoIterator for &'a PortRange {
type Item = u16;
type IntoIter = RangeInclusive<u16>; type IntoIter = RangeInclusive<u16>;
type Item = u16;
fn into_iter(self) -> Self::IntoIter { fn into_iter(self) -> Self::IntoIter {
self.start..=self.end.unwrap_or(self.start) self.start..=self.end.unwrap_or(self.start)
@ -80,8 +79,8 @@ impl<'a> IntoIterator for &'a PortRange {
} }
impl IntoIterator for PortRange { impl IntoIterator for PortRange {
type Item = u16;
type IntoIter = RangeInclusive<u16>; type IntoIter = RangeInclusive<u16>;
type Item = u16;
fn into_iter(self) -> Self::IntoIter { fn into_iter(self) -> Self::IntoIter {
self.start..=self.end.unwrap_or(self.start) self.start..=self.end.unwrap_or(self.start)

@ -1,5 +1,7 @@
use std::time::Duration;
use std::{fmt, io};
use async_trait::async_trait; use async_trait::async_trait;
use std::{fmt, io, time::Duration};
mod framed; mod framed;
pub use framed::*; pub use framed::*;
@ -25,11 +27,10 @@ pub use unix::*;
#[cfg(windows)] #[cfg(windows)]
mod windows; mod windows;
pub use tokio::io::{Interest, Ready};
#[cfg(windows)] #[cfg(windows)]
pub use windows::*; pub use windows::*;
pub use tokio::io::{Interest, Ready};
/// Duration to wait after WouldBlock received during looping operations like `read_exact`. /// Duration to wait after WouldBlock received during looping operations like `read_exact`.
const SLEEP_DURATION: Duration = Duration::from_millis(1); const SLEEP_DURATION: Duration = Duration::from_millis(1);
@ -270,9 +271,10 @@ impl<T: Transport> TransportExt for T {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use test_log::test; use test_log::test;
use super::*;
#[test(tokio::test)] #[test(tokio::test)]
async fn read_exact_should_fail_if_try_read_encounters_error_other_than_would_block() { async fn read_exact_should_fail_if_try_read_encounters_error_other_than_would_block() {
let transport = TestTransport { let transport = TestTransport {

@ -1,10 +1,15 @@
use super::{InmemoryTransport, Interest, Ready, Reconnectable, Transport}; use std::future::Future;
use crate::common::utils; use std::time::Duration;
use std::{fmt, io};
use async_trait::async_trait; use async_trait::async_trait;
use bytes::{Buf, BytesMut}; use bytes::{Buf, BytesMut};
use log::*; use log::*;
use serde::{de::DeserializeOwned, Deserialize, Serialize}; use serde::de::DeserializeOwned;
use std::{fmt, future::Future, io, time::Duration}; use serde::{Deserialize, Serialize};
use super::{InmemoryTransport, Interest, Ready, Reconnectable, Transport};
use crate::common::utils;
mod backup; mod backup;
mod codec; mod codec;
@ -585,6 +590,7 @@ impl<T: Transport> FramedTransport<T> {
pub async fn client_handshake(&mut self) -> io::Result<()> { pub async fn client_handshake(&mut self) -> io::Result<()> {
self.handshake(Handshake::client()).await self.handshake(Handshake::client()).await
} }
/// Shorthand for creating a [`FramedTransport`] with a [`PlainCodec`] and then immediately /// Shorthand for creating a [`FramedTransport`] with a [`PlainCodec`] and then immediately
/// performing a [`server_handshake`], returning the updated [`FramedTransport`] on success. /// performing a [`server_handshake`], returning the updated [`FramedTransport`] on success.
/// ///
@ -905,11 +911,12 @@ impl FramedTransport<InmemoryTransport> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use crate::common::TestTransport;
use bytes::BufMut; use bytes::BufMut;
use test_log::test; use test_log::test;
use super::*;
use crate::common::TestTransport;
/// Codec that always succeeds without altering the frame /// Codec that always succeeds without altering the frame
#[derive(Clone, Debug, PartialEq, Eq)] #[derive(Clone, Debug, PartialEq, Eq)]
struct OkCodec; struct OkCodec;

@ -1,6 +1,7 @@
use super::{Frame, OwnedFrame};
use std::collections::VecDeque; use std::collections::VecDeque;
use super::{Frame, OwnedFrame};
/// Maximum size (in bytes) for saved frames (256MiB) /// Maximum size (in bytes) for saved frames (256MiB)
const MAX_BACKUP_SIZE: usize = 256 * 1024 * 1024; const MAX_BACKUP_SIZE: usize = 256 * 1024 * 1024;

@ -1,7 +1,9 @@
use super::Frame;
use dyn_clone::DynClone;
use std::io; use std::io;
use dyn_clone::DynClone;
use super::Frame;
mod chain; mod chain;
mod compression; mod compression;
mod encryption; mod encryption;

@ -1,6 +1,7 @@
use super::{Codec, Frame};
use std::io; use std::io;
use super::{Codec, Frame};
/// Represents a codec that chains together other codecs such that encoding will call the encode /// Represents a codec that chains together other codecs such that encoding will call the encode
/// methods of the underlying, chained codecs from left-to-right and decoding will call the decode /// methods of the underlying, chained codecs from left-to-right and decoding will call the decode
/// methods in reverse order /// methods in reverse order
@ -59,9 +60,10 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use test_log::test; use test_log::test;
use super::*;
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
struct TestCodec<'a> { struct TestCodec<'a> {
msg: &'a str, msg: &'a str,

@ -1,10 +1,12 @@
use super::{Codec, Frame}; use std::io::{self, Read};
use flate2::{
bufread::{DeflateDecoder, DeflateEncoder, GzDecoder, GzEncoder, ZlibDecoder, ZlibEncoder}, use flate2::bufread::{
Compression, DeflateDecoder, DeflateEncoder, GzDecoder, GzEncoder, ZlibDecoder, ZlibEncoder,
}; };
use flate2::Compression;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::io::{self, Read};
use super::{Codec, Frame};
/// Represents the level of compression to apply to data /// Represents the level of compression to apply to data
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
@ -28,14 +30,12 @@ pub enum CompressionLevel {
} }
impl CompressionLevel { impl CompressionLevel {
/// Applies no compression
pub const NONE: Self = Self::Zero;
/// Applies fastest compression
pub const FAST: Self = Self::One;
/// Applies best compression to reduce size (slowest) /// Applies best compression to reduce size (slowest)
pub const BEST: Self = Self::Nine; pub const BEST: Self = Self::Nine;
/// Applies fastest compression
pub const FAST: Self = Self::One;
/// Applies no compression
pub const NONE: Self = Self::Zero;
} }
impl Default for CompressionLevel { impl Default for CompressionLevel {
@ -186,9 +186,10 @@ impl Codec for CompressionCodec {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use test_log::test; use test_log::test;
use super::*;
#[test] #[test]
fn encode_should_apply_appropriate_compression_algorithm() { fn encode_should_apply_appropriate_compression_algorithm() {
// Encode using DEFLATE and verify that the compression was as expected by decompressing // Encode using DEFLATE and verify that the compression was as expected by decompressing

@ -1,7 +1,9 @@
use super::{Codec, Frame};
use derive_more::Display;
use std::{fmt, io}; use std::{fmt, io};
use derive_more::Display;
use super::{Codec, Frame};
mod key; mod key;
pub use key::*; pub use key::*;
@ -134,7 +136,8 @@ impl Codec for EncryptionCodec {
Ok(match self { Ok(match self {
Self::XChaCha20Poly1305 { cipher } => { Self::XChaCha20Poly1305 { cipher } => {
use chacha20poly1305::{aead::Aead, XNonce}; use chacha20poly1305::aead::Aead;
use chacha20poly1305::XNonce;
let item = frame.into_item(); let item = frame.into_item();
let nonce = XNonce::from_slice(&nonce_bytes); let nonce = XNonce::from_slice(&nonce_bytes);
@ -165,7 +168,8 @@ impl Codec for EncryptionCodec {
// of the frame to tease out the decrypted frame item // of the frame to tease out the decrypted frame item
let item = match self { let item = match self {
Self::XChaCha20Poly1305 { cipher } => { Self::XChaCha20Poly1305 { cipher } => {
use chacha20poly1305::{aead::Aead, XNonce}; use chacha20poly1305::aead::Aead;
use chacha20poly1305::XNonce;
let nonce = XNonce::from_slice(&frame.as_item()[..nonce_size]); let nonce = XNonce::from_slice(&frame.as_item()[..nonce_size]);
cipher cipher
.decrypt(nonce, &frame.as_item()[nonce_size..]) .decrypt(nonce, &frame.as_item()[nonce_size..])
@ -179,9 +183,10 @@ impl Codec for EncryptionCodec {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use test_log::test; use test_log::test;
use super::*;
#[test] #[test]
fn encode_should_build_a_frame_containing_a_length_nonce_and_ciphertext() { fn encode_should_build_a_frame_containing_a_length_nonce_and_ciphertext() {
let ty = EncryptionType::XChaCha20Poly1305; let ty = EncryptionType::XChaCha20Poly1305;
@ -198,7 +203,8 @@ mod tests {
// Manually build our key & cipher so we can decrypt the frame manually to ensure it is // Manually build our key & cipher so we can decrypt the frame manually to ensure it is
// correct // correct
let item = { let item = {
use chacha20poly1305::{aead::Aead, KeyInit, XChaCha20Poly1305, XNonce}; use chacha20poly1305::aead::Aead;
use chacha20poly1305::{KeyInit, XChaCha20Poly1305, XNonce};
let cipher = XChaCha20Poly1305::new_from_slice(&key).unwrap(); let cipher = XChaCha20Poly1305::new_from_slice(&key).unwrap();
cipher cipher
.decrypt(XNonce::from_slice(nonce), ciphertext) .decrypt(XNonce::from_slice(nonce), ciphertext)

@ -1,6 +1,9 @@
use std::fmt;
use std::str::FromStr;
use derive_more::{Display, Error}; use derive_more::{Display, Error};
use rand::{rngs::OsRng, RngCore}; use rand::rngs::OsRng;
use std::{fmt, str::FromStr}; use rand::RngCore;
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
pub struct SecretKeyError; pub struct SecretKeyError;
@ -287,9 +290,10 @@ impl PartialEq<HeapSecretKey> for &str {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use test_log::test; use test_log::test;
use super::*;
#[test] #[test]
fn secret_key_should_be_able_to_be_generated() { fn secret_key_should_be_able_to_be_generated() {
SecretKey::<0>::generate().unwrap_err(); SecretKey::<0>::generate().unwrap_err();

@ -1,6 +1,7 @@
use super::{Codec, Frame};
use std::io; use std::io;
use super::{Codec, Frame};
/// Represents a codec that does not alter the frame (synonymous with "plain text") /// Represents a codec that does not alter the frame (synonymous with "plain text")
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] #[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
pub struct PlainCodec; pub struct PlainCodec;

@ -1,5 +1,7 @@
use std::io;
use std::sync::Arc;
use super::{Codec, Frame}; use super::{Codec, Frame};
use std::{io, sync::Arc};
/// Represents a codec that invokes one of two codecs based on the given predicate /// Represents a codec that invokes one of two codecs based on the given predicate
#[derive(Debug, Default, PartialEq, Eq)] #[derive(Debug, Default, PartialEq, Eq)]
@ -85,9 +87,10 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use test_log::test; use test_log::test;
use super::*;
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
struct TestCodec<'a> { struct TestCodec<'a> {
msg: &'a str, msg: &'a str,

@ -1,8 +1,12 @@
use super::SecretKey32; use std::convert::TryFrom;
use p256::{ecdh::EphemeralSecret, PublicKey}; use std::io;
use p256::ecdh::EphemeralSecret;
use p256::PublicKey;
use rand::rngs::OsRng; use rand::rngs::OsRng;
use sha2::Sha256; use sha2::Sha256;
use std::{convert::TryFrom, io};
use super::SecretKey32;
mod pkb; mod pkb;
pub use pkb::PublicKeyBytes; pub use pkb::PublicKeyBytes;

@ -1,6 +1,8 @@
use std::convert::TryFrom;
use std::io;
use p256::{EncodedPoint, PublicKey}; use p256::{EncodedPoint, PublicKey};
use serde::{Deserialize, Deserializer, Serialize, Serializer}; use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::{convert::TryFrom, io};
/// Represents a wrapper around [`EncodedPoint`], and exists to /// Represents a wrapper around [`EncodedPoint`], and exists to
/// fix an issue with [`serde`] deserialization failing when /// fix an issue with [`serde`] deserialization failing when

@ -1,11 +1,11 @@
use rand::{rngs::OsRng, RngCore}; use std::convert::{TryFrom, TryInto};
use std::ops::BitXor;
use std::str::FromStr;
use std::{fmt, io};
use rand::rngs::OsRng;
use rand::RngCore;
use serde::{Deserialize, Deserializer, Serialize, Serializer}; use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::{
convert::{TryFrom, TryInto},
fmt, io,
ops::BitXor,
str::FromStr,
};
/// Friendly wrapper around a 32-byte array representing a salt /// Friendly wrapper around a 32-byte array representing a salt
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]

@ -1,6 +1,7 @@
use bytes::{Buf, BufMut, BytesMut};
use std::borrow::Cow; use std::borrow::Cow;
use bytes::{Buf, BufMut, BytesMut};
/// Represents a frame whose lifetime is static /// Represents a frame whose lifetime is static
pub type OwnedFrame = Frame<'static>; pub type OwnedFrame = Frame<'static>;
@ -226,9 +227,10 @@ impl<'a, const N: usize> PartialEq<&'a [u8; N]> for Frame<'_> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use test_log::test; use test_log::test;
use super::*;
#[test] #[test]
fn write_should_succeed_when_item_is_zero_bytes() { fn write_should_succeed_when_item_is_zero_bytes() {
let frame = Frame::new(&[]); let frame = Frame::new(&[]);

@ -1,13 +1,11 @@
use super::{Interest, Ready, Reconnectable, Transport}; use std::io;
use std::sync::{Mutex, MutexGuard};
use async_trait::async_trait; use async_trait::async_trait;
use std::{ use tokio::sync::mpsc::error::{TryRecvError, TrySendError};
io, use tokio::sync::mpsc::{self};
sync::{Mutex, MutexGuard},
}; use super::{Interest, Ready, Reconnectable, Transport};
use tokio::sync::mpsc::{
self,
error::{TryRecvError, TrySendError},
};
/// Represents a [`Transport`] comprised of two inmemory channels /// Represents a [`Transport`] comprised of two inmemory channels
#[derive(Debug)] #[derive(Debug)]
@ -202,9 +200,10 @@ fn copy_and_store(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use test_log::test;
use super::*; use super::*;
use crate::common::TransportExt; use crate::common::TransportExt;
use test_log::test;
#[test] #[test]
fn is_rx_closed_should_properly_reflect_if_internal_rx_channel_is_closed() { fn is_rx_closed_should_properly_reflect_if_internal_rx_channel_is_closed() {

@ -1,8 +1,11 @@
use super::{Interest, Ready, Reconnectable, Transport}; use std::net::IpAddr;
use std::{fmt, io};
use async_trait::async_trait; use async_trait::async_trait;
use std::{fmt, io, net::IpAddr};
use tokio::net::{TcpStream, ToSocketAddrs}; use tokio::net::{TcpStream, ToSocketAddrs};
use super::{Interest, Ready, Reconnectable, Transport};
/// Represents a [`Transport`] that leverages a TCP stream /// Represents a [`Transport`] that leverages a TCP stream
pub struct TcpTransport { pub struct TcpTransport {
pub(crate) addr: IpAddr, pub(crate) addr: IpAddr,
@ -68,11 +71,15 @@ impl Transport for TcpTransport {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use crate::common::TransportExt;
use std::net::{Ipv6Addr, SocketAddr}; use std::net::{Ipv6Addr, SocketAddr};
use test_log::test; use test_log::test;
use tokio::{net::TcpListener, sync::oneshot, task::JoinHandle}; use tokio::net::TcpListener;
use tokio::sync::oneshot;
use tokio::task::JoinHandle;
use super::*;
use crate::common::TransportExt;
async fn find_ephemeral_addr() -> SocketAddr { async fn find_ephemeral_addr() -> SocketAddr {
// Start a listener on a distinct port, get its port, and kill it // Start a listener on a distinct port, get its port, and kill it

@ -1,7 +1,9 @@
use super::{Interest, Ready, Reconnectable, Transport};
use async_trait::async_trait;
use std::{fmt, io}; use std::{fmt, io};
use async_trait::async_trait;
use super::{Interest, Ready, Reconnectable, Transport};
pub type TryReadFn = Box<dyn Fn(&mut [u8]) -> io::Result<usize> + Send + Sync>; pub type TryReadFn = Box<dyn Fn(&mut [u8]) -> io::Result<usize> + Send + Sync>;
pub type TryWriteFn = Box<dyn Fn(&[u8]) -> io::Result<usize> + Send + Sync>; pub type TryWriteFn = Box<dyn Fn(&[u8]) -> io::Result<usize> + Send + Sync>;
pub type ReadyFn = Box<dyn Fn(Interest) -> io::Result<Ready> + Send + Sync>; pub type ReadyFn = Box<dyn Fn(Interest) -> io::Result<Ready> + Send + Sync>;

@ -1,11 +1,11 @@
use super::{Interest, Ready, Reconnectable, Transport}; use std::path::{Path, PathBuf};
use std::{fmt, io};
use async_trait::async_trait; use async_trait::async_trait;
use std::{
fmt, io,
path::{Path, PathBuf},
};
use tokio::net::UnixStream; use tokio::net::UnixStream;
use super::{Interest, Ready, Reconnectable, Transport};
/// Represents a [`Transport`] that leverages a Unix socket /// Represents a [`Transport`] that leverages a Unix socket
pub struct UnixSocketTransport { pub struct UnixSocketTransport {
pub(crate) path: PathBuf, pub(crate) path: PathBuf,
@ -61,16 +61,15 @@ impl Transport for UnixSocketTransport {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use crate::common::TransportExt;
use tempfile::NamedTempFile; use tempfile::NamedTempFile;
use test_log::test; use test_log::test;
use tokio::{ use tokio::io::{AsyncReadExt, AsyncWriteExt};
io::{AsyncReadExt, AsyncWriteExt}, use tokio::net::UnixListener;
net::UnixListener, use tokio::sync::oneshot;
sync::oneshot, use tokio::task::JoinHandle;
task::JoinHandle,
}; use super::*;
use crate::common::TransportExt;
async fn start_and_run_server(tx: oneshot::Sender<PathBuf>) -> io::Result<()> { async fn start_and_run_server(tx: oneshot::Sender<PathBuf>) -> io::Result<()> {
// Generate a socket path and delete the file after so there is nothing there // Generate a socket path and delete the file after so there is nothing there

@ -1,9 +1,9 @@
use super::{Interest, Ready, Reconnectable, Transport}; use std::ffi::{OsStr, OsString};
use std::{fmt, io};
use async_trait::async_trait; use async_trait::async_trait;
use std::{
ffi::{OsStr, OsString}, use super::{Interest, Ready, Reconnectable, Transport};
fmt, io,
};
mod pipe; mod pipe;
pub use pipe::NamedPipe; pub use pipe::NamedPipe;
@ -87,14 +87,13 @@ impl Transport for WindowsPipeTransport {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use test_log::test;
use tokio::net::windows::named_pipe::{NamedPipeServer, ServerOptions};
use tokio::sync::oneshot;
use tokio::task::JoinHandle;
use super::*; use super::*;
use crate::common::TransportExt; use crate::common::TransportExt;
use test_log::test;
use tokio::{
net::windows::named_pipe::{NamedPipeServer, ServerOptions},
sync::oneshot,
task::JoinHandle,
};
async fn start_and_run_server(tx: oneshot::Sender<String>) -> io::Result<()> { async fn start_and_run_server(tx: oneshot::Sender<String>) -> io::Result<()> {
let pipe = start_server(tx).await?; let pipe = start_server(tx).await?;

@ -1,5 +1,8 @@
use std::ffi::OsStr;
use std::io;
use std::time::Duration;
use derive_more::{From, TryInto}; use derive_more::{From, TryInto};
use std::{ffi::OsStr, io, time::Duration};
use tokio::net::windows::named_pipe::{ClientOptions, NamedPipeClient, NamedPipeServer}; use tokio::net::windows::named_pipe::{ClientOptions, NamedPipeClient, NamedPipeServer};
// Equivalent to winapi::shared::winerror::ERROR_PIPE_BUSY // Equivalent to winapi::shared::winerror::ERROR_PIPE_BUSY

@ -1,10 +1,14 @@
use serde::{ use std::future::Future;
de::{DeserializeOwned, Deserializer, Error as SerdeError, Visitor}, use std::marker::PhantomData;
ser::Serializer, use std::str::FromStr;
Serialize, use std::time::Duration;
}; use std::{fmt, io};
use std::{fmt, future::Future, io, marker::PhantomData, str::FromStr, time::Duration};
use tokio::{sync::mpsc, task::JoinHandle}; use serde::de::{DeserializeOwned, Deserializer, Error as SerdeError, Visitor};
use serde::ser::Serializer;
use serde::Serialize;
use tokio::sync::mpsc;
use tokio::task::JoinHandle;
pub fn serialize_to_vec<T: Serialize>(value: &T) -> io::Result<Vec<u8>> { pub fn serialize_to_vec<T: Serialize>(value: &T) -> io::Result<Vec<u8>> {
rmp_serde::encode::to_vec_named(value) rmp_serde::encode::to_vec_named(value)
@ -142,9 +146,10 @@ mod tests {
use super::*; use super::*;
mod timer { mod timer {
use super::*;
use test_log::test; use test_log::test;
use super::*;
#[test(tokio::test)] #[test(tokio::test)]
async fn should_not_invoke_callback_regardless_of_time_if_not_started() { async fn should_not_invoke_callback_regardless_of_time_if_not_started() {
let timer = Timer::new(Duration::default(), async {}); let timer = Timer::new(Duration::default(), async {});

@ -5,6 +5,4 @@ pub mod server;
pub use client::{Client, ReconnectStrategy}; pub use client::{Client, ReconnectStrategy};
pub use server::Server; pub use server::Server;
pub use {log, paste};
pub use log;
pub use paste;

@ -1,19 +1,15 @@
use crate::{
client::Client,
common::{
authentication::{
msg::{Authentication, AuthenticationResponse},
AuthHandler,
},
ConnectionId, Destination, Map, Request,
},
manager::data::{
ConnectionInfo, ConnectionList, ManagerCapabilities, ManagerRequest, ManagerResponse,
},
};
use log::*;
use std::io; use std::io;
use log::*;
use crate::client::Client;
use crate::common::authentication::msg::{Authentication, AuthenticationResponse};
use crate::common::authentication::AuthHandler;
use crate::common::{ConnectionId, Destination, Map, Request};
use crate::manager::data::{
ConnectionInfo, ConnectionList, ManagerCapabilities, ManagerRequest, ManagerResponse,
};
mod channel; mod channel;
pub use channel::*; pub use channel::*;

@ -1,16 +1,15 @@
use crate::{ use std::io;
client::{Client, ClientConfig, UntypedClient}, use std::ops::{Deref, DerefMut};
common::{ConnectionId, FramedTransport, InmemoryTransport, UntypedRequest},
manager::data::{ManagerRequest, ManagerResponse},
};
use log::*; use log::*;
use serde::{de::DeserializeOwned, Serialize}; use serde::de::DeserializeOwned;
use std::{ use serde::Serialize;
io,
ops::{Deref, DerefMut},
};
use tokio::task::JoinHandle; use tokio::task::JoinHandle;
use crate::client::{Client, ClientConfig, UntypedClient};
use crate::common::{ConnectionId, FramedTransport, InmemoryTransport, UntypedRequest};
use crate::manager::data::{ManagerRequest, ManagerResponse};
/// Represents a raw channel between a manager client and server. Underneath, this routes incoming /// Represents a raw channel between a manager client and server. Underneath, this routes incoming
/// and outgoing data from a proxied server to an inmemory transport. /// and outgoing data from a proxied server to an inmemory transport.
pub struct RawChannel { pub struct RawChannel {

@ -1,15 +1,15 @@
use super::ManagerCapabilityKind; use std::cmp::Ordering;
use std::collections::HashSet;
use std::hash::{Hash, Hasher};
use std::ops::{BitAnd, BitOr, BitXor};
use std::str::FromStr;
use derive_more::{From, Into, IntoIterator}; use derive_more::{From, Into, IntoIterator};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{
cmp::Ordering,
collections::HashSet,
hash::{Hash, Hasher},
ops::{BitAnd, BitOr, BitXor},
str::FromStr,
};
use strum::{EnumMessage, IntoEnumIterator}; use strum::{EnumMessage, IntoEnumIterator};
use super::ManagerCapabilityKind;
/// Set of supported capabilities for a manager /// Set of supported capabilities for a manager
#[derive(Clone, Debug, From, Into, PartialEq, Eq, IntoIterator, Serialize, Deserialize)] #[derive(Clone, Debug, From, Into, PartialEq, Eq, IntoIterator, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]

@ -1,6 +1,7 @@
use crate::common::{ConnectionId, Destination, Map};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::common::{ConnectionId, Destination, Map};
/// Information about a specific connection /// Information about a specific connection
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ConnectionInfo { pub struct ConnectionInfo {

@ -1,10 +1,10 @@
use crate::common::{ConnectionId, Destination}; use std::collections::HashMap;
use std::ops::{Deref, DerefMut, Index, IndexMut};
use derive_more::IntoIterator; use derive_more::IntoIterator;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{
collections::HashMap, use crate::common::{ConnectionId, Destination};
ops::{Deref, DerefMut, Index, IndexMut},
};
/// Represents a list of information about active connections /// Represents a list of information about active connections
#[derive(Clone, Debug, PartialEq, Eq, IntoIterator, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, IntoIterator, Serialize, Deserialize)]

@ -1,11 +1,11 @@
use super::{ManagerAuthenticationId, ManagerChannelId};
use crate::common::{
authentication::msg::AuthenticationResponse, ConnectionId, Destination, Map, UntypedRequest,
};
use derive_more::IsVariant; use derive_more::IsVariant;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use strum::{AsRefStr, EnumDiscriminants, EnumIter, EnumMessage, EnumString}; use strum::{AsRefStr, EnumDiscriminants, EnumIter, EnumMessage, EnumString};
use super::{ManagerAuthenticationId, ManagerChannelId};
use crate::common::authentication::msg::AuthenticationResponse;
use crate::common::{ConnectionId, Destination, Map, UntypedRequest};
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
#[derive(Clone, Debug, EnumDiscriminants, Serialize, Deserialize)] #[derive(Clone, Debug, EnumDiscriminants, Serialize, Deserialize)]
#[strum_discriminants(derive( #[strum_discriminants(derive(

@ -1,10 +1,10 @@
use serde::{Deserialize, Serialize};
use super::{ use super::{
ConnectionInfo, ConnectionList, ManagerAuthenticationId, ManagerCapabilities, ManagerChannelId, ConnectionInfo, ConnectionList, ManagerAuthenticationId, ManagerCapabilities, ManagerChannelId,
}; };
use crate::common::{ use crate::common::authentication::msg::Authentication;
authentication::msg::Authentication, ConnectionId, Destination, UntypedResponse, use crate::common::{ConnectionId, Destination, UntypedResponse};
};
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "snake_case", deny_unknown_fields, tag = "type")] #[serde(rename_all = "snake_case", deny_unknown_fields, tag = "type")]

@ -1,16 +1,19 @@
use crate::{ use std::collections::HashMap;
common::{authentication::msg::AuthenticationResponse, ConnectionId, Destination, Map}, use std::io;
manager::{ use std::sync::Arc;
ConnectionInfo, ConnectionList, ManagerAuthenticationId, ManagerCapabilities,
ManagerChannelId, ManagerRequest, ManagerResponse,
},
server::{Server, ServerCtx, ServerHandler},
};
use async_trait::async_trait; use async_trait::async_trait;
use log::*; use log::*;
use std::{collections::HashMap, io, sync::Arc};
use tokio::sync::{oneshot, RwLock}; use tokio::sync::{oneshot, RwLock};
use crate::common::authentication::msg::AuthenticationResponse;
use crate::common::{ConnectionId, Destination, Map};
use crate::manager::{
ConnectionInfo, ConnectionList, ManagerAuthenticationId, ManagerCapabilities, ManagerChannelId,
ManagerRequest, ManagerResponse,
};
use crate::server::{Server, ServerCtx, ServerHandler};
mod authentication; mod authentication;
pub use authentication::*; pub use authentication::*;
@ -183,9 +186,9 @@ pub struct DistantManagerServerConnection {
#[async_trait] #[async_trait]
impl ServerHandler for ManagerServer { impl ServerHandler for ManagerServer {
type LocalData = DistantManagerServerConnection;
type Request = ManagerRequest; type Request = ManagerRequest;
type Response = ManagerResponse; type Response = ManagerResponse;
type LocalData = DistantManagerServerConnection;
async fn on_request(&self, ctx: ServerCtx<Self::Request, Self::Response, Self::LocalData>) { async fn on_request(&self, ctx: ServerCtx<Self::Request, Self::Response, Self::LocalData>) {
let ServerCtx { let ServerCtx {
@ -315,12 +318,13 @@ impl ServerHandler for ManagerServer {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use tokio::sync::mpsc;
use super::*; use super::*;
use crate::client::UntypedClient; use crate::client::UntypedClient;
use crate::common::FramedTransport; use crate::common::FramedTransport;
use crate::server::ServerReply; use crate::server::ServerReply;
use crate::{boxed_connect_handler, boxed_launch_handler}; use crate::{boxed_connect_handler, boxed_launch_handler};
use tokio::sync::mpsc;
fn test_config() -> Config { fn test_config() -> Config {
Config { Config {

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save