Add macros to derive message serializations.

This commit is contained in:
Drew Galbraith 2024-07-27 18:30:17 -07:00
parent ccd13fecf1
commit 8f35d38e93
11 changed files with 284 additions and 108 deletions

View file

@ -0,0 +1,38 @@
#![no_std]
extern crate alloc;
use alloc::string::String;
use alloc::string::ToString;
use mammoth::syscall::z_cap_t;
use mammoth::syscall::ZError;
use yunq::ByteBuffer;
use yunq::YunqMessage;
use yunq_derive::YunqMessage;
#[derive(YunqMessage)]
pub struct GetEndpointRequest {
pub endpoint_name: String,
}
#[derive(YunqMessage)]
pub struct Endpoint {
pub endpoint: z_cap_t,
}
pub struct YellowstoneClient {
endpoint_cap: z_cap_t,
byte_buffer: ByteBuffer<0x1000>,
}
impl YellowstoneClient {
pub fn new(endpoint_cap: z_cap_t) -> Self {
Self {
endpoint_cap,
byte_buffer: ByteBuffer::new(),
}
}
pub fn get_endpoint(&mut self, req: &GetEndpointRequest) -> Result<Endpoint, ZError> {
yunq::client::call_endpoint(req, &mut self.byte_buffer, self.endpoint_cap)
}
}