Run cargo fmt

Signed-off-by: Alex Kattathra Johnson <alex.kattathra.johnson@gmail.com>
This commit is contained in:
Alex Kattathra Johnson 2024-12-06 17:07:09 -06:00
parent 5f35894619
commit e35542ddf3
No known key found for this signature in database
GPG key ID: 64BCC76905798553
3 changed files with 14 additions and 17 deletions

View file

@ -1,8 +1,11 @@
use std::time::Duration; use std::time::Duration;
use nu_plugin::{EvaluatedCall, JsonSerializer, serve_plugin}; use nu_plugin::{serve_plugin, EvaluatedCall, JsonSerializer};
use nu_plugin::{EngineInterface, Plugin, PluginCommand}; use nu_plugin::{EngineInterface, Plugin, PluginCommand};
use nu_protocol::{ByteStream, ByteStreamType, Category, LabeledError, PipelineData, Signature, SyntaxShape, Type, Value}; use nu_protocol::{
ByteStream, ByteStreamType, Category, LabeledError, PipelineData, Signature, SyntaxShape, Type,
Value,
};
mod ws; mod ws;
use ws::client::{connect, http_parse_url, request_headers}; use ws::client::{connect, http_parse_url, request_headers};
@ -15,9 +18,7 @@ impl Plugin for WebSocketPlugin {
} }
fn commands(&self) -> Vec<Box<dyn PluginCommand<Plugin = Self>>> { fn commands(&self) -> Vec<Box<dyn PluginCommand<Plugin = Self>>> {
vec![ vec![Box::new(WebSocket)]
Box::new(WebSocket),
]
} }
} }
@ -80,11 +81,7 @@ impl PluginCommand for WebSocket {
.expect("Timeout should be set to duration") as u64, .expect("Timeout should be set to duration") as u64,
) )
}); });
if let Some(cr) = connect( if let Some(cr) = connect(requested_url, timeout, request_headers(headers)?) {
requested_url,
timeout,
request_headers(headers)?,
) {
let reader = Box::new(cr); let reader = Box::new(cr);
return Ok(PipelineData::ByteStream( return Ok(PipelineData::ByteStream(
ByteStream::read( ByteStream::read(

View file

@ -100,17 +100,17 @@ pub fn connect(
tungstenite::Message::Text(msg) => { tungstenite::Message::Text(msg) => {
if tx.send(msg.as_bytes().to_vec()).is_err() { if tx.send(msg.as_bytes().to_vec()).is_err() {
websocket.close(Some(tungstenite::protocol::CloseFrame{ websocket.close(Some(tungstenite::protocol::CloseFrame{
code: tungstenite::protocol::frame::coding::CloseCode::Normal, code: tungstenite::protocol::frame::coding::CloseCode::Normal,
reason: std::borrow::Cow::Borrowed("byte stream closed"), reason: std::borrow::Cow::Borrowed("byte stream closed"),
})).expect("Could not close connection") })).expect("Could not close connection")
} }
} }
tungstenite::Message::Binary(msg) => { tungstenite::Message::Binary(msg) => {
if tx.send(msg).is_err() { if tx.send(msg).is_err() {
websocket.close(Some(tungstenite::protocol::CloseFrame{ websocket.close(Some(tungstenite::protocol::CloseFrame{
code: tungstenite::protocol::frame::coding::CloseCode::Normal, code: tungstenite::protocol::frame::coding::CloseCode::Normal,
reason: std::borrow::Cow::Borrowed("byte stream closed"), reason: std::borrow::Cow::Borrowed("byte stream closed"),
})).expect("Could not close connection") })).expect("Could not close connection")
} }
} }
tungstenite::Message::Close(..) => { tungstenite::Message::Close(..) => {