refactor(proto): replace anyhow with thiserror in writers
This commit is contained in:
parent
bb39d138d8
commit
58c69928a1
5 changed files with 21 additions and 6 deletions
|
|
@ -2,13 +2,14 @@ use crate::message::proto_message::ProtoMessage;
|
|||
use crate::writer::protowriter::ProtoWriter;
|
||||
use async_trait::async_trait;
|
||||
use tokio::io::{AsyncWrite, AsyncWriteExt};
|
||||
use crate::writer::errors::ProtoWriteError;
|
||||
|
||||
#[async_trait]
|
||||
pub trait OneWayProtoWriter<T>
|
||||
where
|
||||
T: ProtoMessage,
|
||||
{
|
||||
async fn write_proto(&mut self, message: T) -> anyhow::Result<()>;
|
||||
async fn write_proto(&mut self, message: T) -> Result<(), ProtoWriteError>;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
|
|
@ -17,7 +18,7 @@ where
|
|||
W: AsyncWrite + Unpin + Send,
|
||||
T: ProtoMessage + Send + 'static,
|
||||
{
|
||||
async fn write_proto(&mut self, message: T) -> anyhow::Result<()> {
|
||||
async fn write_proto(&mut self, message: T) -> Result<(), ProtoWriteError> {
|
||||
let variant = message.variant();
|
||||
let mut data = message.serialize()?;
|
||||
let length = data.len() as i32 + 4;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue