mirror of
https://github.com/htrefil/rkvm.git
synced 2024-12-26 09:58:32 +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",
|
"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]]
|
[[package]]
|
||||||
name = "atty"
|
name = "atty"
|
||||||
version = "0.2.14"
|
version = "0.2.14"
|
||||||
|
@ -848,7 +837,6 @@ dependencies = [
|
||||||
name = "rkvm-net"
|
name = "rkvm-net"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
|
||||||
"bincode",
|
"bincode",
|
||||||
"hmac",
|
"hmac",
|
||||||
"rand",
|
"rand",
|
||||||
|
|
|
@ -11,7 +11,6 @@ rkvm-input = { path = "../rkvm-input" }
|
||||||
serde = { version = "1.0.117", features = ["derive"] }
|
serde = { version = "1.0.117", features = ["derive"] }
|
||||||
bincode = "1.3.3"
|
bincode = "1.3.3"
|
||||||
tokio = { version = "1.0.1", features = ["io-util"] }
|
tokio = { version = "1.0.1", features = ["io-util"] }
|
||||||
async-trait = "0.1.68"
|
|
||||||
thiserror = "1.0.40"
|
thiserror = "1.0.40"
|
||||||
hmac = "0.12.1"
|
hmac = "0.12.1"
|
||||||
sha2 = "0.10.6"
|
sha2 = "0.10.6"
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
// This is not really public API.
|
||||||
|
#![allow(async_fn_in_trait)]
|
||||||
|
|
||||||
pub mod auth;
|
pub mod auth;
|
||||||
pub mod message;
|
pub mod message;
|
||||||
pub mod version;
|
pub mod version;
|
||||||
|
|
|
@ -4,14 +4,12 @@ use serde::Serialize;
|
||||||
use std::io::{Error, ErrorKind};
|
use std::io::{Error, ErrorKind};
|
||||||
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
|
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
|
||||||
pub trait Message: Sized {
|
pub trait Message: Sized {
|
||||||
async fn decode<R: AsyncRead + Send + Unpin>(stream: &mut R) -> Result<Self, Error>;
|
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 fn encode<W: AsyncWrite + Send + Unpin>(&self, stream: &mut W) -> Result<(), Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
|
||||||
impl<T: DeserializeOwned + Serialize + Sync> Message for T {
|
impl<T: DeserializeOwned + Serialize + Sync> Message for T {
|
||||||
async fn decode<R: AsyncRead + Send + Unpin>(stream: &mut R) -> Result<Self, Error> {
|
async fn decode<R: AsyncRead + Send + Unpin>(stream: &mut R) -> Result<Self, Error> {
|
||||||
let length = stream.read_u16().await?;
|
let length = stream.read_u16().await?;
|
||||||
|
|
|
@ -17,7 +17,6 @@ impl Display for Version {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
|
||||||
impl Message for Version {
|
impl Message for Version {
|
||||||
async fn decode<R: AsyncRead + Send + Unpin>(stream: &mut R) -> Result<Self, Error> {
|
async fn decode<R: AsyncRead + Send + Unpin>(stream: &mut R) -> Result<Self, Error> {
|
||||||
stream.read_u16_le().await.map(Self)
|
stream.read_u16_le().await.map(Self)
|
||||||
|
|
Loading…
Reference in a new issue