mirror of
https://github.com/actix/examples
synced 2025-06-26 17:17:42 +02:00
fmt
This commit is contained in:
@ -68,11 +68,7 @@ impl Decoder for ChatCodec {
|
||||
impl Encoder<ChatResponse> for ChatCodec {
|
||||
type Error = io::Error;
|
||||
|
||||
fn encode(
|
||||
&mut self,
|
||||
msg: ChatResponse,
|
||||
dst: &mut BytesMut,
|
||||
) -> Result<(), Self::Error> {
|
||||
fn encode(&mut self, msg: ChatResponse, dst: &mut BytesMut) -> Result<(), Self::Error> {
|
||||
let msg = json::to_string(&msg).unwrap();
|
||||
let msg_ref: &[u8] = msg.as_ref();
|
||||
|
||||
@ -112,11 +108,7 @@ impl Decoder for ClientChatCodec {
|
||||
impl Encoder<ChatRequest> for ClientChatCodec {
|
||||
type Error = io::Error;
|
||||
|
||||
fn encode(
|
||||
&mut self,
|
||||
msg: ChatRequest,
|
||||
dst: &mut BytesMut,
|
||||
) -> Result<(), Self::Error> {
|
||||
fn encode(&mut self, msg: ChatRequest, dst: &mut BytesMut) -> Result<(), Self::Error> {
|
||||
let msg = json::to_string(&msg).unwrap();
|
||||
let msg_ref: &[u8] = msg.as_ref();
|
||||
|
||||
|
@ -2,9 +2,7 @@ use std::time::{Duration, Instant};
|
||||
|
||||
use actix::prelude::*;
|
||||
use actix_files::NamedFile;
|
||||
use actix_web::{
|
||||
middleware::Logger, web, App, Error, HttpRequest, HttpServer, Responder,
|
||||
};
|
||||
use actix_web::{middleware::Logger, web, App, Error, HttpRequest, HttpServer, Responder};
|
||||
use actix_web_actors::ws;
|
||||
|
||||
mod codec;
|
||||
@ -103,11 +101,7 @@ impl Handler<session::Message> for WsChatSession {
|
||||
|
||||
/// WebSocket message handler
|
||||
impl StreamHandler<Result<ws::Message, ws::ProtocolError>> for WsChatSession {
|
||||
fn handle(
|
||||
&mut self,
|
||||
msg: Result<ws::Message, ws::ProtocolError>,
|
||||
ctx: &mut Self::Context,
|
||||
) {
|
||||
fn handle(&mut self, msg: Result<ws::Message, ws::ProtocolError>, ctx: &mut Self::Context) {
|
||||
let msg = match msg {
|
||||
Err(_) => {
|
||||
ctx.stop();
|
||||
|
Reference in New Issue
Block a user