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

rust/oak_abi: Make oak_abi #643

Merged
merged 3 commits into from
Feb 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 6 additions & 1 deletion oak/server/rust/oak_abi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ authors = ["David Drysdale <drysdale@google.com>"]
edition = "2018"
license = "Apache-2.0"

[features]
std = ["protobuf"]
no_std = []
default = ["std"]

[dependencies]
protobuf = "*"
protobuf = { version = "*", optional = true }

[build-dependencies]
oak_utils = "*"
Expand Down
43 changes: 40 additions & 3 deletions oak/server/rust/oak_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,47 @@

//! Type, constant and Wasm host function definitions for the Oak application binary interface.

pub use proto::oak_api::ChannelReadStatus;
pub use proto::oak_api::OakStatus;

// TODO(#638): Generate from protobuf in a no_std compatible way
#[cfg(feature = "std")]
pub mod proto;
#[cfg(feature = "std")]
mod inner {
pub use super::proto::oak_api::{ChannelReadStatus, OakStatus};
}

#[cfg(feature = "no_std")]
mod inner {
#![allow(dead_code)]
#![allow(missing_docs)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]

#[derive(Clone, PartialEq, Eq, Debug, Hash)]
pub enum OakStatus {
OAK_STATUS_UNSPECIFIED = 0,
OK = 1,
ERR_BAD_HANDLE = 2,
ERR_INVALID_ARGS = 3,
ERR_CHANNEL_CLOSED = 4,
ERR_BUFFER_TOO_SMALL = 5,
ERR_HANDLE_SPACE_TOO_SMALL = 6,
ERR_OUT_OF_RANGE = 7,
ERR_INTERNAL = 8,
ERR_TERMINATED = 9,
ERR_CHANNEL_EMPTY = 10,
}

#[derive(Clone, PartialEq, Eq, Debug, Hash)]
pub enum ChannelReadStatus {
NOT_READY = 0,
READ_READY = 1,
INVALID_CHANNEL = 2,
ORPHANED = 3,
}
}

pub use inner::*;

/// Handle used to identify read or write channel halves.
///
Expand Down
6 changes: 3 additions & 3 deletions oak/server/rust/oak_runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ edition = "2018"
license = "Apache-2.0"

[features]
std = ["no-std-compat/std"]
no_std = []
std = ["no-std-compat/std", "oak_abi/std"]
no_std = ["oak_abi/no_std"]
default = ["std"]

[dependencies]
byteorder = { version = "*", default-features = false }
itertools = "*"
log = { version = "*" }
oak_abi = "=0.1.0"
oak_abi = { version = "=0.1.0", default-features = false }
protobuf = "*"
rand = { version = "*" }
wasmi = { version = "*", default-features = false, features = ["core"] }
Expand Down