Skip to content

Commit

Permalink
Add support for setting network buffers. (#31)
Browse files Browse the repository at this point in the history
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
  • Loading branch information
PiotrSikora authored Aug 15, 2020
1 parent 8d1dd06 commit 6f32085
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ pub trait StreamContext: Context {
hostcalls::get_buffer(BufferType::DownstreamData, start, max_size).unwrap()
}

fn set_downstream_data(&self, start: usize, size: usize, value: &[u8]) {
hostcalls::set_buffer(BufferType::DownstreamData, start, size, value).unwrap()
}

fn on_downstream_close(&mut self, _peer_type: PeerType) {}

fn on_upstream_data(&mut self, _data_size: usize, _end_of_stream: bool) -> Action {
Expand All @@ -146,6 +150,10 @@ pub trait StreamContext: Context {
hostcalls::get_buffer(BufferType::UpstreamData, start, max_size).unwrap()
}

fn set_upstream_data(&self, start: usize, size: usize, value: &[u8]) {
hostcalls::set_buffer(BufferType::UpstreamData, start, size, value).unwrap()
}

fn on_upstream_close(&mut self, _peer_type: PeerType) {}

fn on_log(&mut self) {}
Expand Down

0 comments on commit 6f32085

Please sign in to comment.