diff --git a/oak/server/rust/oak_abi/Cargo.toml b/oak/server/rust/oak_abi/Cargo.toml index f686bc0ee70..528fae3d8f2 100644 --- a/oak/server/rust/oak_abi/Cargo.toml +++ b/oak/server/rust/oak_abi/Cargo.toml @@ -5,8 +5,13 @@ authors = ["David Drysdale "] edition = "2018" license = "Apache-2.0" +[features] +std = ["protobuf"] +no_std = [] +default = ["std"] + [dependencies] -protobuf = "*" +protobuf = { version = "*", optional = true } [build-dependencies] oak_utils = "*" diff --git a/oak/server/rust/oak_abi/src/lib.rs b/oak/server/rust/oak_abi/src/lib.rs index d9b0ac8494b..531684d7c9d 100644 --- a/oak/server/rust/oak_abi/src/lib.rs +++ b/oak/server/rust/oak_abi/src/lib.rs @@ -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. /// diff --git a/oak/server/rust/oak_runtime/Cargo.toml b/oak/server/rust/oak_runtime/Cargo.toml index e4c050989b5..1a39abad0f9 100644 --- a/oak/server/rust/oak_runtime/Cargo.toml +++ b/oak/server/rust/oak_runtime/Cargo.toml @@ -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"] }