Sending struct using crossbeam_channel::bounded

I have very simple struct:

struct WSReadFrame {
    opcode: u8,
    payload: Vec<u8>,

In code I need to send it via crossbeam_channel::bounded like so

let (s, r) = bounded::<WSReadFrame>(1024);


let send_frame: WSReadFrame = WSReadFrame::new(...);

What I don't get in this snippet is that what will actually happen:

  • send_frame will be moved and only its pointer will actually be sent over the channel, and no bytes will be copied?
  • during send rust will move send_frame and actually send all its content?

Pairs of send/recv are analogous to vec.push() and vec.pop().


So it will send only pointer, right ?

Only the opcode, as well as the pointer, length and capacity of the vector are actually copied. The contents behind the pointer is not.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.