mirror of
https://framagit.org/ppom/reaction
synced 2026-03-14 20:55:47 +01:00
Remove more dead code
Client/Daemon communication is now JSON so we don't need This quirks anymore
This commit is contained in:
parent
fb9c0f8699
commit
fe1a93b8a2
4 changed files with 0 additions and 58 deletions
|
|
@ -44,7 +44,6 @@ pub struct Filter {
|
|||
}
|
||||
|
||||
impl Filter {
|
||||
|
||||
pub fn name(&self) -> &str {
|
||||
&self.name
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
mod messages;
|
||||
mod serialization;
|
||||
|
||||
pub use messages::*;
|
||||
pub use serialization::*;
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
use std::marker::PhantomData;
|
||||
|
||||
use serde::de::DeserializeOwned;
|
||||
use thiserror::Error;
|
||||
use tokio_util::codec::{Decoder, LengthDelimitedCodec};
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum DecodeError {
|
||||
#[error("{0}")]
|
||||
Io(#[from] tokio::io::Error),
|
||||
#[error("{0}")]
|
||||
Json(#[from] serde_json::Error),
|
||||
}
|
||||
|
||||
pub struct LengthPrefixedBincode<T: DeserializeOwned> {
|
||||
inner: LengthDelimitedCodec,
|
||||
_marker: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T: DeserializeOwned> LengthPrefixedBincode<T> {
|
||||
pub fn new() -> Self {
|
||||
LengthPrefixedBincode {
|
||||
inner: LengthDelimitedCodec::new(),
|
||||
_marker: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: DeserializeOwned> Default for LengthPrefixedBincode<T> {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: DeserializeOwned> Decoder for LengthPrefixedBincode<T> {
|
||||
type Item = T;
|
||||
type Error = DecodeError;
|
||||
|
||||
fn decode(
|
||||
&mut self,
|
||||
src: &mut tokio_util::bytes::BytesMut,
|
||||
) -> Result<Option<Self::Item>, Self::Error> {
|
||||
match self.inner.decode(src) {
|
||||
Ok(Some(data)) => match serde_json::from_slice(&data) {
|
||||
Ok(thing) => Ok(Some(thing)),
|
||||
Err(err) => Err(err.into()),
|
||||
},
|
||||
Ok(None) => Ok(None),
|
||||
Err(err) => Err(err.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue