Add Pages and Bytes newtypes

This commit is contained in:
Lachlan Sneff
2019-01-29 15:44:15 -08:00
parent bc78738bb7
commit 69e9c5154d
16 changed files with 278 additions and 138 deletions

View File

@ -140,6 +140,20 @@ impl PartialEq for CallError {
}
}
/// This error type is produced when creating something,
/// like a `Memory` or a `Table`.
#[derive(Debug, Clone)]
pub enum CreationError {
UnableToCreateMemory,
UnableToCreateTable,
}
impl PartialEq for CreationError {
fn eq(&self, _other: &CreationError) -> bool {
false
}
}
/// The amalgamation of all errors that can occur
/// during the compilation, instantiation, or execution
/// of a webassembly module.
@ -152,6 +166,7 @@ pub enum Error {
RuntimeError(RuntimeError),
ResolveError(ResolveError),
CallError(CallError),
CreationError(CreationError),
}
impl PartialEq for Error {
@ -220,6 +235,12 @@ impl From<CallError> for Box<Error> {
}
}
impl From<CreationError> for Box<Error> {
fn from(creation_err: CreationError) -> Self {
Box::new(Error::CreationError(creation_err))
}
}
impl From<RuntimeError> for Box<CallError> {
fn from(runtime_err: RuntimeError) -> Self {
Box::new(CallError::Runtime(runtime_err))