2023-12-24 15:48:33 -05:00
|
|
|
use crate::error::CustomError;
|
|
|
|
|
2023-12-27 12:20:58 -05:00
|
|
|
pub trait ToWasm<'p> {
|
2023-12-24 15:48:33 -05:00
|
|
|
type Output;
|
|
|
|
|
2023-12-27 12:20:58 -05:00
|
|
|
fn to_wasm(&'p self, full_document: ToWasmContext<'_>) -> Result<Self::Output, CustomError>;
|
2023-12-24 15:48:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) trait ToWasmStandardProperties {
|
|
|
|
type Output;
|
|
|
|
|
|
|
|
fn to_wasm_standard_properties(
|
|
|
|
&self,
|
|
|
|
wasm_context: ToWasmContext<'_>,
|
|
|
|
) -> Result<Self::Output, CustomError>;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
2023-12-27 12:20:58 -05:00
|
|
|
pub struct ToWasmContext<'s> {
|
2023-12-24 15:48:33 -05:00
|
|
|
pub(crate) full_document: &'s str,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'s> ToWasmContext<'s> {
|
2023-12-27 12:20:58 -05:00
|
|
|
pub fn new(full_document: &'s str) -> ToWasmContext<'s> {
|
2023-12-24 15:48:33 -05:00
|
|
|
ToWasmContext { full_document }
|
|
|
|
}
|
|
|
|
}
|