use quick_error::quick_error;
use std::{ffi::NulError, str};
mod runtime;
pub use runtime::Runtime;
pub mod context;
pub use context::{Context, ContextBuilder, Ctx, Globals};
mod markers;
mod value;
use std::result::Result as StdResult;
use std::string::String as StdString;
pub use value::*;
quick_error! {
#[derive(Debug,Clone,PartialEq)]
pub enum Error{
Allocation{
display("Allocation failed while creating object")
}
InvalidString(e: NulError){
display("string contained internal null bytes: {}",e)
from()
cause(e)
}
Utf8(e: str::Utf8Error){
display("Conversion from string failed: {}",e)
from()
cause(e)
}
Unknown{
display("quickjs library created a unknown error")
}
Exception(e: StdString){
display("exception generated by quickjs: {}",e)
}
FromJsConversion{from: &'static str, to: &'static str, message: Option<StdString>} {
display("error converting from js from type '{}', to '{}': {}",from,to,message.as_ref().unwrap_or(&StdString::new()))
}
ToJsConversion{from: &'static str, to: &'static str, message: Option<StdString>} {
display("error converting from type '{}', to '{}': {}",from,to,message.as_ref().unwrap_or(&StdString::new()))
}
}
}
pub type Result<T> = StdResult<T, Error>;
#[cfg(test)]
mod test {
use super::*;
#[test]
fn base_runtime() {
let _rt = Runtime::new().unwrap();
}
}