Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server::send_text_owned #36

Merged
merged 4 commits into from
Jun 11, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,15 @@ impl<T: AsyncRead + AsyncWrite + Unpin> Sender<T> {
self.send_frame(&mut header, &mut Storage::Shared(data.as_ref().as_bytes())).await
}

/// Send a text value over the websocket connection.
///
/// In contrast to [`Sender::send_text`] the provided data is modified
/// in-place, e.g. if masking is necessary.
maciejhirsz marked this conversation as resolved.
Show resolved Hide resolved
pub async fn send_text_owned(&mut self, data: String) -> Result<(), Error> {
let mut header = Header::new(OpCode::Text);
self.send_frame(&mut header, &mut Storage::Owned(data.into_bytes())).await
}

/// Send some binary data over the websocket connection.
pub async fn send_binary(&mut self, data: impl AsRef<[u8]>) -> Result<(), Error> {
let mut header = Header::new(OpCode::Binary);
Expand Down