mirror of
https://github.com/htrefil/rkvm.git
synced 2024-12-25 09:58:18 +01:00
Get rid of async-trait
This commit is contained in:
parent
6ecf7ba80f
commit
9e9b74d768
5 changed files with 3 additions and 16 deletions
12
Cargo.lock
generated
12
Cargo.lock
generated
|
@ -75,17 +75,6 @@ dependencies = [
|
|||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
version = "0.1.81"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
|
@ -848,7 +837,6 @@ dependencies = [
|
|||
name = "rkvm-net"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"bincode",
|
||||
"hmac",
|
||||
"rand",
|
||||
|
|
|
@ -11,7 +11,6 @@ rkvm-input = { path = "../rkvm-input" }
|
|||
serde = { version = "1.0.117", features = ["derive"] }
|
||||
bincode = "1.3.3"
|
||||
tokio = { version = "1.0.1", features = ["io-util"] }
|
||||
async-trait = "0.1.68"
|
||||
thiserror = "1.0.40"
|
||||
hmac = "0.12.1"
|
||||
sha2 = "0.10.6"
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// This is not really public API.
|
||||
#![allow(async_fn_in_trait)]
|
||||
|
||||
pub mod auth;
|
||||
pub mod message;
|
||||
pub mod version;
|
||||
|
|
|
@ -4,14 +4,12 @@ use serde::Serialize;
|
|||
use std::io::{Error, ErrorKind};
|
||||
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
|
||||
|
||||
#[async_trait::async_trait]
|
||||
pub trait Message: Sized {
|
||||
async fn decode<R: AsyncRead + Send + Unpin>(stream: &mut R) -> Result<Self, Error>;
|
||||
|
||||
async fn encode<W: AsyncWrite + Send + Unpin>(&self, stream: &mut W) -> Result<(), Error>;
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl<T: DeserializeOwned + Serialize + Sync> Message for T {
|
||||
async fn decode<R: AsyncRead + Send + Unpin>(stream: &mut R) -> Result<Self, Error> {
|
||||
let length = stream.read_u16().await?;
|
||||
|
|
|
@ -17,7 +17,6 @@ impl Display for Version {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Message for Version {
|
||||
async fn decode<R: AsyncRead + Send + Unpin>(stream: &mut R) -> Result<Self, Error> {
|
||||
stream.read_u16_le().await.map(Self)
|
||||
|
|
Loading…
Reference in a new issue