use alloc::vec::Vec;
use crate::batch::Runtime;
use crate::ipc::{DecodeError, DecodedData, EncodedData};
pub trait BinaryEncode<P = ()> {
fn encode(self, encoder: &mut EncodedData);
}
pub trait BinaryDecode: Sized {
fn decode(decoder: &mut DecodedData) -> Result<Self, DecodeError>;
}
pub trait IntoClosure<M, Output> {
fn into_closure(self) -> Output;
}
pub trait BatchableResult: BinaryDecode {
fn try_placeholder(_: &mut Runtime) -> Option<Self> {
None
}
}
pub(crate) const TYPE_CACHED: u8 = 0xFF;
pub(crate) const TYPE_FULL: u8 = 0xFE;
#[repr(u8)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum TypeTag {
Null = 0,
Bool = 1,
U8 = 2,
U16 = 3,
U32 = 4,
U64 = 5,
U128 = 6,
I8 = 7,
I16 = 8,
I32 = 9,
I64 = 10,
I128 = 11,
F32 = 12,
F64 = 13,
Usize = 14,
Isize = 15,
String = 16,
HeapRef = 17,
Callback = 18,
Option = 19,
Result = 20,
Array = 21,
BorrowedRef = 22,
U8Clamped = 23,
StringEnum = 24,
}
pub trait EncodeTypeDef {
fn encode_type_def(buf: &mut Vec<u8>);
}
mod callbacks;
mod clamped;
mod containers;
mod primitives;
#[cfg(test)]
mod tests;
mod values;
pub use callbacks::CallbackKey;
pub(crate) use callbacks::CallbackPolicy;