Merge pull request #1897 from Andrew15-5/fix-liveview-adapter-comments
docs(liveview): fixed adapter comments
This commit is contained in:
4 files changed
+9
-9
No files matched your search
@@ -2,9 +2,9 @@ use crate::{LiveViewError, LiveViewSocket};
|
|||||||
use axum::extract::ws::{Message, WebSocket};
|
use axum::extract::ws::{Message, WebSocket};
|
||||||
use futures_util::{SinkExt, StreamExt};
|
use futures_util::{SinkExt, StreamExt};
|
||||||
|
|
||||||
/// Convert a warp websocket into a LiveViewSocket
|
/// Convert an Axum WebSocket into a `LiveViewSocket`.
|
||||||
///
|
///
|
||||||
/// This is required to launch a LiveView app using the warp web framework
|
/// This is required to launch a LiveView app using the Axum web framework.
|
||||||
pub fn axum_socket(ws: WebSocket) -> impl LiveViewSocket {
|
pub fn axum_socket(ws: WebSocket) -> impl LiveViewSocket {
|
||||||
ws.map(transform_rx)
|
ws.map(transform_rx)
|
||||||
.with(transform_tx)
|
.with(transform_tx)
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ use crate::{LiveViewError, LiveViewSocket};
|
|||||||
use rocket::futures::{SinkExt, StreamExt};
|
use rocket::futures::{SinkExt, StreamExt};
|
||||||
use rocket_ws::{result::Error, stream::DuplexStream, Message};
|
use rocket_ws::{result::Error, stream::DuplexStream, Message};
|
||||||
|
|
||||||
/// Convert a rocket websocket into a LiveViewSocket
|
/// Convert a Rocket WebSocket into a `LiveViewSocket`.
|
||||||
///
|
///
|
||||||
/// This is required to launch a LiveView app using the rocket web framework
|
/// This is required to launch a LiveView app using the Rocket web framework.
|
||||||
pub fn rocket_socket(stream: DuplexStream) -> impl LiveViewSocket {
|
pub fn rocket_socket(stream: DuplexStream) -> impl LiveViewSocket {
|
||||||
stream
|
stream
|
||||||
.map(transform_rx)
|
.map(transform_rx)
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ use salvo::ws::{Message, WebSocket};
|
|||||||
|
|
||||||
use crate::{LiveViewError, LiveViewSocket};
|
use crate::{LiveViewError, LiveViewSocket};
|
||||||
|
|
||||||
/// Convert a salvo websocket into a LiveViewSocket
|
/// Convert a Salvo WebSocket into a `LiveViewSocket`.
|
||||||
///
|
///
|
||||||
/// This is required to launch a LiveView app using the warp web framework
|
/// This is required to launch a LiveView app using the Salvo web framework.
|
||||||
pub fn salvo_socket(ws: WebSocket) -> impl LiveViewSocket {
|
pub fn salvo_socket(ws: WebSocket) -> impl LiveViewSocket {
|
||||||
ws.map(transform_rx)
|
ws.map(transform_rx)
|
||||||
.with(transform_tx)
|
.with(transform_tx)
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ use crate::{LiveViewError, LiveViewSocket};
|
|||||||
use futures_util::{SinkExt, StreamExt};
|
use futures_util::{SinkExt, StreamExt};
|
||||||
use warp::ws::{Message, WebSocket};
|
use warp::ws::{Message, WebSocket};
|
||||||
|
|
||||||
/// Convert a warp websocket into a LiveViewSocket
|
/// Convert a warp WebSocket into a `LiveViewSocket`.
|
||||||
///
|
///
|
||||||
/// This is required to launch a LiveView app using the warp web framework
|
/// This is required to launch a LiveView app using the warp web framework.
|
||||||
pub fn warp_socket(ws: WebSocket) -> impl LiveViewSocket {
|
pub fn warp_socket(ws: WebSocket) -> impl LiveViewSocket {
|
||||||
ws.map(transform_rx)
|
ws.map(transform_rx)
|
||||||
.with(transform_tx)
|
.with(transform_tx)
|
||||||
@@ -12,7 +12,7 @@ pub fn warp_socket(ws: WebSocket) -> impl LiveViewSocket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn transform_rx(message: Result<Message, warp::Error>) -> Result<Vec<u8>, LiveViewError> {
|
fn transform_rx(message: Result<Message, warp::Error>) -> Result<Vec<u8>, LiveViewError> {
|
||||||
// destructure the message into the buffer we got from warp
|
// Destructure the `message` into the buffer we got from warp.
|
||||||
let msg = message
|
let msg = message
|
||||||
.map_err(|_| LiveViewError::SendingFailed)?
|
.map_err(|_| LiveViewError::SendingFailed)?
|
||||||
.into_bytes();
|
.into_bytes();
|
||||||
|
|||||||
Reference in new issue
Block a user