mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-26 21:41:08 +00:00
Sandboxing and the simplest smart-contract runtime (#140)
* Add primitives for sandboxing. * Add sandbox module. * Implement the runtime part of the sandbox. * Rebuild binaries. * Implement smart-contract execution. * Add more documentation.
This commit is contained in:
committed by
Robert Habermeier
parent
f116f67382
commit
5a56fbcea3
@@ -61,6 +61,31 @@ pub trait Slicable: Sized {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Slicable, E: Slicable> Slicable for Result<T, E> {
|
||||
fn decode<I: Input>(input: &mut I) -> Option<Self> {
|
||||
match input.read_byte()? {
|
||||
0 => Some(Ok(T::decode(input)?)),
|
||||
1 => Some(Err(E::decode(input)?)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn encode(&self) -> Vec<u8> {
|
||||
let mut v = Vec::new();
|
||||
match *self {
|
||||
Ok(ref t) => {
|
||||
v.push(0);
|
||||
t.using_encoded(|s| v.extend(s));
|
||||
}
|
||||
Err(ref e) => {
|
||||
v.push(1);
|
||||
e.using_encoded(|s| v.extend(s));
|
||||
}
|
||||
}
|
||||
v
|
||||
}
|
||||
}
|
||||
|
||||
impl Slicable for Option<bool> {
|
||||
fn decode<I: Input>(input: &mut I) -> Option<Self> {
|
||||
match input.read_byte()? {
|
||||
|
||||
Reference in New Issue
Block a user