mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-04-28 23:48:00 +00:00
cargo fmt
This commit is contained in:
@@ -13,13 +13,13 @@
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
use super::on_close::OnClose;
|
||||
use futures::channel::mpsc;
|
||||
use futures::{SinkExt, StreamExt};
|
||||
use soketto::handshake::{Client, ServerResponse};
|
||||
use std::sync::Arc;
|
||||
use tokio::net::TcpStream;
|
||||
use tokio_util::compat::TokioAsyncReadCompatExt;
|
||||
use std::sync::Arc;
|
||||
use super::on_close::OnClose;
|
||||
|
||||
use super::{
|
||||
receiver::{Receiver, RecvMessage},
|
||||
@@ -89,7 +89,10 @@ impl Connection {
|
||||
Err(e) => {
|
||||
// The socket had an error, so notify interested parties that we should
|
||||
// shut the connection down and bail out of this receive loop.
|
||||
log::error!("Shutting down websocket connection: Failed to receive data: {}", e);
|
||||
log::error!(
|
||||
"Shutting down websocket connection: Failed to receive data: {}",
|
||||
e
|
||||
);
|
||||
let _ = tx_closed1.send(());
|
||||
break;
|
||||
}
|
||||
@@ -198,14 +201,16 @@ impl Connection {
|
||||
// been dropped. If both have, we close the socket connection.
|
||||
let on_close = Arc::new(OnClose(tx_closed2));
|
||||
|
||||
(Sender {
|
||||
inner: tx_to_ws,
|
||||
closer: Arc::clone(&on_close),
|
||||
},
|
||||
Receiver {
|
||||
inner: rx_from_ws,
|
||||
closer: on_close,
|
||||
})
|
||||
(
|
||||
Sender {
|
||||
inner: tx_to_ws,
|
||||
closer: Arc::clone(&on_close),
|
||||
},
|
||||
Receiver {
|
||||
inner: rx_from_ws,
|
||||
closer: on_close,
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
/// Functionality to establish a connection
|
||||
mod connect;
|
||||
/// A close helper that we use in sender/receiver.
|
||||
mod on_close;
|
||||
/// The channel based receive interface
|
||||
mod receiver;
|
||||
/// The channel based send interface
|
||||
mod sender;
|
||||
/// A close helper that we use in sender/receiver.
|
||||
mod on_close;
|
||||
|
||||
pub use connect::{connect, ConnectError, Connection, RawReceiver, RawSender};
|
||||
pub use receiver::{Receiver, RecvError, RecvMessage};
|
||||
|
||||
@@ -23,4 +23,4 @@ impl Drop for OnClose {
|
||||
fn drop(&mut self) {
|
||||
let _ = self.0.send(());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use super::on_close::OnClose;
|
||||
use futures::channel::mpsc;
|
||||
use futures::{Stream, StreamExt};
|
||||
use std::sync::Arc;
|
||||
use super::on_close::OnClose;
|
||||
|
||||
/// Receive messages out of a connection
|
||||
pub struct Receiver {
|
||||
@@ -32,7 +32,7 @@ pub enum RecvError {
|
||||
#[error("Stream finished")]
|
||||
StreamFinished,
|
||||
#[error("Failed to send close message")]
|
||||
CloseError
|
||||
CloseError,
|
||||
}
|
||||
|
||||
impl Receiver {
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use super::on_close::OnClose;
|
||||
use futures::channel::mpsc;
|
||||
use futures::{Sink, SinkExt};
|
||||
use std::sync::Arc;
|
||||
use super::on_close::OnClose;
|
||||
|
||||
/// A message that can be sent into the channel interface
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -70,7 +70,7 @@ pub enum SendError {
|
||||
#[error("Failed to send message: {0}")]
|
||||
ChannelError(#[from] mpsc::SendError),
|
||||
#[error("Failed to send close message")]
|
||||
CloseError
|
||||
CloseError,
|
||||
}
|
||||
|
||||
impl Sink<SentMessage> for Sender {
|
||||
@@ -85,9 +85,7 @@ impl Sink<SentMessage> for Sender {
|
||||
mut self: std::pin::Pin<&mut Self>,
|
||||
item: SentMessage,
|
||||
) -> Result<(), Self::Error> {
|
||||
self.inner
|
||||
.start_send_unpin(item)
|
||||
.map_err(|e| e.into())
|
||||
self.inner.start_send_unpin(item).map_err(|e| e.into())
|
||||
}
|
||||
fn poll_flush(
|
||||
mut self: std::pin::Pin<&mut Self>,
|
||||
|
||||
Reference in New Issue
Block a user