use std::any::{TypeId, type_name};
use crate::runtime::NoCtx;
pub unsafe trait Context: 'static + Clone {
fn fields() -> Vec<ContextField>;
fn description() -> ContextDescription {
ContextDescription {
type_id: TypeId::of::<Self>(),
type_name: type_name::<Self>(),
fields: Self::fields(),
}
}
}
#[derive(Clone)]
pub struct ContextDescription {
pub type_id: TypeId,
pub type_name: &'static str,
pub fields: Vec<ContextField>,
}
#[derive(Clone, Debug)]
pub struct ContextField {
pub name: &'static str,
pub offset: usize,
pub type_name: &'static str,
pub type_id: TypeId,
pub docstring: String,
}
unsafe impl Context for NoCtx {
fn fields() -> Vec<ContextField> {
Vec::new()
}
}