scatter_net/legacy/interaction/methods/
send_bytes.rs1use bytes::Bytes;
2use iroh::endpoint::{SendDatagramError, WriteError};
3
4use crate::Interaction;
5
6impl Interaction {
7 pub async fn send_bytes(&self, bytes: Bytes) -> Result<(), InteractionSendBytesError> {
8 self.send_stream
9 .lock()
10 .await
11 .write_all(bytes.as_ref())
12 .await
13 .map_err(Into::into)
14 }
15}
16
17#[derive(thiserror::Error, Debug)]
18pub enum InteractionSendBytesError {
19 #[error("Failed to send datagram: {0}")]
20 SendDatagramError(#[from] SendDatagramError),
21 #[error("Failed to write data: {0}")]
22 WriteError(#[from] WriteError),
23}