Skip to content

Commit

Permalink
Add TODO to simplify Borrow<T> to &T.
Browse files Browse the repository at this point in the history
To be done once linear handles are the default.
  • Loading branch information
wildarch committed Feb 12, 2021
1 parent c4bf283 commit e6a2489
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions sdk/rust/oak/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ fn send_init<Init, Command, InitSender>(
where
Init: Encodable + Decodable,
Command: Encodable + Decodable,
// TODO(#1854): Only accept references once handles are always linear types
InitSender: Borrow<Sender<oak_io::InitWrapper<Init, Command>>>,
{
let (command_sender, command_receiver) =
Expand Down
5 changes: 5 additions & 0 deletions sdk/rust/oak/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pub mod proto {

// Build a chunk of memory that is suitable for passing to oak_abi::wait_on_channels,
// holding the given collection of channel handles.
// TODO(#1854): Only accept &[&ReadHandle] once handles are always linear types
fn new_handle_space<R: Borrow<ReadHandle>>(handles: &[R]) -> Vec<u8> {
let mut space = Vec::with_capacity(oak_abi::SPACE_BYTES_PER_HANDLE * handles.len());
for handle in handles {
Expand Down Expand Up @@ -95,6 +96,7 @@ fn prep_handle_space(space: &mut [u8]) {
/// This is a convenience wrapper around the [`oak_abi::wait_on_channels`] host
/// function. This version is easier to use in Rust but is less efficient
/// (because the notification space is re-created on each invocation).
// TODO(#1854): Only accept &[&ReadHandle] once handles are always linear types
pub fn wait_on_channels<R: Borrow<ReadHandle>>(
handles: &[R],
) -> Result<Vec<ChannelReadStatus>, OakStatus> {
Expand Down Expand Up @@ -125,6 +127,7 @@ pub fn wait_on_channels<R: Borrow<ReadHandle>>(
/// The provided vectors for received data and associated handles will be
/// resized to accommodate the information in the message; any data already
/// held in the vectors will be overwritten.
// TODO(#1854): Only accept &ReadHandle once handles are always linear types
pub fn channel_read<R: Borrow<ReadHandle>>(
half: R,
buf: &mut Vec<u8>,
Expand Down Expand Up @@ -213,6 +216,7 @@ pub fn channel_read<R: Borrow<ReadHandle>>(
}

/// Write a message to a channel.
// TODO(#1854): Only accept &WriteHandle once handles are always linear types
pub fn channel_write<W: Borrow<WriteHandle>>(
half: W,
buf: &[u8],
Expand All @@ -233,6 +237,7 @@ pub fn channel_write<W: Borrow<WriteHandle>>(

/// The same as [`channel_write`](#method.channel_write), but also applies the current Node's
/// downgrade privilege when checking IFC restrictions.
// TODO(#1854): Only accept &WriteHandle once handles are always linear types
pub fn channel_write_with_downgrade<W: Borrow<WriteHandle>>(
half: W,
buf: &[u8],
Expand Down

0 comments on commit e6a2489

Please sign in to comment.