Skip to content

Commit 1bde9d3

Browse files
committed
Removed unused code.
1 parent 5d6d547 commit 1bde9d3

File tree

13 files changed

+40
-370
lines changed

13 files changed

+40
-370
lines changed

client/fixture/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use swimos_remote::dns::{BoxDnsResolver, DnsResolver};
2121
use swimos_remote::net::{
2222
ClientConnections, ConnResult, ConnectionError, IoResult, Listener, ListenerError, Scheme,
2323
};
24-
use swimos_remote::ws::{RatchetError, WebsocketClient, WebsocketServer, WsOpenFuture};
24+
use swimos_remote::websocket::{RatchetError, WebsocketClient, WebsocketServer, WsOpenFuture};
2525
use swimos_remote::FindNode;
2626
use tokio::io::{AsyncRead, AsyncWrite, DuplexStream};
2727
use tokio::sync::mpsc;

client/runtime/src/runtime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use std::num::NonZeroUsize;
2626
use std::sync::Arc;
2727
use swimos_remote::{
2828
net::{Scheme, SchemeHostPort},
29-
ws::WebsocketClient,
29+
websocket::WebsocketClient,
3030
};
3131
use tokio::sync::{mpsc, oneshot, Notify};
3232
use tokio::task::{JoinError, JoinHandle};

client/runtime/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ use swimos_downlink::{
5454
use swimos_form::Form;
5555
use swimos_messages::protocol::{RawRequestMessageEncoder, RequestMessage};
5656
use swimos_model::Text;
57-
use swimos_remote::ws::RatchetError;
57+
use swimos_remote::websocket::RatchetError;
5858
use swimos_remote::AttachClient;
5959
use swimos_runtime::downlink::{DownlinkOptions, DownlinkRuntimeConfig};
6060
use swimos_utilities::byte_channel::{byte_channel, ByteReader, ByteWriter};

client/runtime/src/transport.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use std::net::SocketAddr;
2525
use std::num::NonZeroUsize;
2626
use std::time::Duration;
2727
use swimos_remote::net::{ClientConnections, Scheme, SchemeHostPort};
28-
use swimos_remote::ws::WebsocketClient;
28+
use swimos_remote::websocket::WebsocketClient;
2929
use swimos_remote::{AttachClient, RemoteTask};
3030
use swimos_utilities::trigger;
3131
use tokio::select;

client/swimos_client/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use ratchet::NoExtProvider;
1717
use ratchet::WebSocketStream;
1818
use std::marker::PhantomData;
1919
use std::num::NonZeroUsize;
20-
use swimos_remote::ws::RatchetClient;
20+
use swimos_remote::websocket::RatchetClient;
2121

2222
use futures_util::future::BoxFuture;
2323
#[cfg(feature = "deflate")]

runtime/swimos_remote/src/dns.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,16 @@ pub struct Resolver {
8383
impl Resolver {
8484
#[cfg(feature = "trust-dns")]
8585
pub async fn new() -> Resolver {
86-
Resolver { inner: trust_dns_impl::TrustDnsResolver::new().await }
86+
Resolver {
87+
inner: trust_dns_impl::TrustDnsResolver::new().await,
88+
}
8789
}
8890

8991
#[cfg(not(feature = "trust-dns"))]
9092
pub async fn new() -> Resolver {
91-
Resolver { inner: GetAddressInfoResolver }
93+
Resolver {
94+
inner: GetAddressInfoResolver,
95+
}
9296
}
9397
}
9498

runtime/swimos_remote/src/lib.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,19 @@ pub mod dns;
1616
mod error;
1717
pub mod net;
1818
mod task;
19-
pub mod ws;
19+
mod ws;
2020

2121
pub use error::{AgentResolutionError, NoSuchAgent};
2222
pub use task::{AttachClient, FindNode, LinkError, NodeConnectionRequest, RemoteTask};
2323

2424
#[cfg(feature = "tls")]
2525
pub mod tls;
26+
27+
pub mod websocket {
28+
29+
pub use super::ws::{
30+
RatchetClient, RatchetError, WebsocketClient, WebsocketServer, Websockets, WsOpenFuture,
31+
};
32+
33+
pub const WARP: &str = "warp0";
34+
}

runtime/swimos_remote/src/ws/mod.rs

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,21 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use std::collections::HashSet;
1615
use std::fmt::Debug;
1716
use std::net::SocketAddr;
18-
use std::sync::OnceLock;
1917

2018
use futures::future::BoxFuture;
2119
use futures::Stream;
2220
use swimos_utilities::errors::Recoverable;
23-
use tokio::net::TcpStream;
2421

2522
use ratchet::{ExtensionProvider, ProtocolRegistry, WebSocket, WebSocketConfig, WebSocketStream};
26-
pub use swimos_ratchet::*;
27-
pub use switcher::StreamSwitcher;
2823
use thiserror::Error;
2924
use tokio::sync::mpsc;
3025

3126
use crate::net::{Listener, ListenerError};
27+
use crate::websocket::WARP;
3228
use crate::FindNode;
3329

34-
mod swimos_ratchet;
35-
36-
mod switcher;
37-
3830
#[derive(Debug, Error)]
3931
#[error("{0}")]
4032
pub struct RatchetError(#[from] ratchet::Error);
@@ -44,10 +36,6 @@ impl Recoverable for RatchetError {
4436
}
4537
}
4638

47-
pub type WebSocketDef<E> = WebSocket<TcpStream, E>;
48-
49-
pub type StreamDef = TcpStream;
50-
5139
pub type WsOpenFuture<'l, Sock, Ext, Error> = BoxFuture<'l, Result<WebSocket<Sock, Ext>, Error>>;
5240

5341
/// Trait for adapters that will negotiate a client websocket connection over an duplex connection.
@@ -109,16 +97,6 @@ impl From<WebSocketConfig> for RatchetClient {
10997
}
11098
}
11199

112-
static PROTOCOLS: OnceLock<HashSet<&'static str>> = OnceLock::new();
113-
114-
pub fn protocols() -> &'static HashSet<&'static str> {
115-
PROTOCOLS.get_or_init(|| {
116-
let mut s = HashSet::new();
117-
s.insert("warp0");
118-
s
119-
})
120-
}
121-
122100
impl WebsocketClient for RatchetClient {
123101
fn open_connection<'a, Sock, Provider>(
124102
&self,
@@ -133,7 +111,7 @@ impl WebsocketClient for RatchetClient {
133111
{
134112
let config = self.0;
135113
Box::pin(async move {
136-
let subprotocols = ProtocolRegistry::new(protocols().iter().copied())?;
114+
let subprotocols = ProtocolRegistry::new([WARP])?;
137115
let socket = ratchet::subscribe_with(config, socket, addr, provider, subprotocols)
138116
.await?
139117
.into_websocket();

0 commit comments

Comments
 (0)