mirror of
https://github.com/MercuryWorkshop/epoxy-tls.git
synced 2025-05-12 22:10:01 -04:00
remove ws_stream_wasm, wisp_mux 1.1.2
This commit is contained in:
parent
06d3225721
commit
1bf1a809bd
7 changed files with 202 additions and 114 deletions
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "wisp-mux"
|
||||
version = "1.1.1"
|
||||
version = "1.1.2"
|
||||
license = "AGPL-3.0-only"
|
||||
description = "A library for easily creating Wisp servers and clients."
|
||||
homepage = "https://github.com/MercuryWorkshop/epoxy-tls/tree/multiplexed/wisp"
|
||||
|
@ -20,13 +20,12 @@ hyper-util-wasm = { version = "0.1.3", features = ["client", "client-legacy"], o
|
|||
pin-project-lite = "0.2.13"
|
||||
tokio = { version = "1.35.1", optional = true, default-features = false }
|
||||
tower-service = { version = "0.3.2", optional = true }
|
||||
ws_stream_wasm = { version = "0.7.4", optional = true }
|
||||
|
||||
[features]
|
||||
fastwebsockets = ["dep:fastwebsockets", "dep:tokio"]
|
||||
ws_stream_wasm = ["dep:ws_stream_wasm"]
|
||||
tokio_io = ["async_io_stream/tokio_io"]
|
||||
hyper_tower = ["dep:tower-service", "dep:hyper", "dep:tokio", "dep:hyper-util-wasm"]
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
features = ["hyper_tower"]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
|
|
@ -1,21 +1,23 @@
|
|||
#![deny(missing_docs)]
|
||||
#![feature(impl_trait_in_assoc_type)]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
//! A library for easily creating [Wisp] clients and servers.
|
||||
//!
|
||||
//! [Wisp]: https://github.com/MercuryWorkshop/wisp-protocol
|
||||
|
||||
#[cfg(feature = "fastwebsockets")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "fastwebsockets")))]
|
||||
mod fastwebsockets;
|
||||
mod packet;
|
||||
mod sink_unfold;
|
||||
mod stream;
|
||||
#[cfg(feature = "hyper_tower")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "hyper_tower")))]
|
||||
pub mod tokioio;
|
||||
#[cfg(feature = "hyper_tower")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "hyper_tower")))]
|
||||
pub mod tower;
|
||||
pub mod ws;
|
||||
#[cfg(feature = "ws_stream_wasm")]
|
||||
mod ws_stream_wasm;
|
||||
|
||||
pub use crate::packet::*;
|
||||
pub use crate::stream::*;
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
use futures::{stream::{SplitStream, SplitSink}, SinkExt, StreamExt};
|
||||
use ws_stream_wasm::{WsErr, WsMessage, WsStream};
|
||||
|
||||
impl From<WsMessage> for crate::ws::Frame {
|
||||
fn from(msg: WsMessage) -> Self {
|
||||
use crate::ws::OpCode;
|
||||
match msg {
|
||||
WsMessage::Text(str) => Self {
|
||||
finished: true,
|
||||
opcode: OpCode::Text,
|
||||
payload: str.into(),
|
||||
},
|
||||
WsMessage::Binary(bin) => Self {
|
||||
finished: true,
|
||||
opcode: OpCode::Binary,
|
||||
payload: bin.into(),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<crate::ws::Frame> for WsMessage {
|
||||
type Error = crate::WispError;
|
||||
fn try_from(msg: crate::ws::Frame) -> Result<Self, Self::Error> {
|
||||
use crate::ws::OpCode;
|
||||
match msg.opcode {
|
||||
OpCode::Text => Ok(Self::Text(std::str::from_utf8(&msg.payload)?.to_string())),
|
||||
OpCode::Binary => Ok(Self::Binary(msg.payload.to_vec())),
|
||||
_ => Err(Self::Error::WsImplNotSupported),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<WsErr> for crate::WispError {
|
||||
fn from(err: WsErr) -> Self {
|
||||
Self::WsImplError(Box::new(err))
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::ws::WebSocketRead for SplitStream<WsStream> {
|
||||
async fn wisp_read_frame(
|
||||
&mut self,
|
||||
_: &crate::ws::LockedWebSocketWrite<impl crate::ws::WebSocketWrite>,
|
||||
) -> Result<crate::ws::Frame, crate::WispError> {
|
||||
Ok(self
|
||||
.next()
|
||||
.await
|
||||
.ok_or(crate::WispError::WsImplSocketClosed)?
|
||||
.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::ws::WebSocketWrite for SplitSink<WsStream, WsMessage> {
|
||||
async fn wisp_write_frame(&mut self, frame: crate::ws::Frame) -> Result<(), crate::WispError> {
|
||||
self
|
||||
.send(frame.try_into()?)
|
||||
.await
|
||||
.map_err(|e| e.into())
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue