raw_struct 0.1.3

raw_struct is a Rust procedural macro for easily declaring C-style structs that reference local or external memory, based on your memory implementation. It generates appropiate getter methods for easy access.
Documentation
use alloc::borrow::Cow;

use crate::memory::MemoryView;

pub trait ViewableBase: Send + Sync {
    fn object_memory(&self) -> &dyn MemoryView;
}

pub trait ViewableImplementation<M: MemoryView, T: ?Sized>: ViewableBase {
    fn memory(&self) -> &M;
    fn as_trait(&self) -> &T;
}

pub trait Viewable<T: ?Sized>: 'static {
    type Memory: Copy + Send + Sync;
    type Implementation<M: MemoryView + 'static>: ViewableImplementation<M, T>;

    const MEMORY_SIZE: usize = core::mem::size_of::<Self::Memory>();

    fn create<M: MemoryView + 'static>(memory: M) -> Self::Implementation<M>;
    fn name() -> Cow<'static, str>;
}