1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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();
}
}