Skip to content

Commit

Permalink
refactor: delegate send to non-generic variant
Browse files Browse the repository at this point in the history
  • Loading branch information
threadexio committed May 4, 2024
1 parent 013e2a1 commit 3c42c40
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions channels/src/sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,14 @@ where
where
D: Borrow<T>,
{
let payload = self.serialize_t(data.borrow())?;
self._send(data.borrow()).await
}

async fn _send(
&mut self,
data: &T,
) -> Result<(), SendError<S::Error, W::Error>> {
let payload = self.serialize_t(data)?;

crate::protocol::send_async(
&self.config,
Expand Down Expand Up @@ -324,7 +331,14 @@ where
where
D: Borrow<T>,
{
let payload = self.serialize_t(data.borrow())?;
self._send_blocking(data.borrow())
}

fn _send_blocking(
&mut self,
data: &T,
) -> Result<(), SendError<S::Error, W::Error>> {
let payload = self.serialize_t(data)?;

crate::protocol::send_sync(
&self.config,
Expand Down

0 comments on commit 3c42c40

Please sign in to comment.