Traditional route appears to work

Beginnings of dylib extensions, entirely untestted
This commit is contained in:
2026-01-12 01:38:10 +01:00
parent 32d6237dc5
commit 1a7230ce9b
40 changed files with 1560 additions and 1135 deletions

View File

@@ -34,23 +34,18 @@ use crate::{Sweeped, atom, expr, interner, lexer, logging, parser, system, tree}
static HOST_INTRO: &[u8] = b"Orchid host, binary API v0\n";
#[derive(Clone, Debug)]
pub struct HostHeader {
pub log_strategy: logging::LogStrategy,
pub msg_logs: logging::LogStrategy,
pub logger: logging::Logger,
}
impl Decode for HostHeader {
async fn decode<R: AsyncRead + ?Sized>(mut read: Pin<&mut R>) -> io::Result<Self> {
read_exact(read.as_mut(), HOST_INTRO).await?;
Ok(Self {
log_strategy: logging::LogStrategy::decode(read.as_mut()).await?,
msg_logs: logging::LogStrategy::decode(read.as_mut()).await?,
})
Ok(Self { logger: logging::Logger::decode(read).await? })
}
}
impl Encode for HostHeader {
async fn encode<W: AsyncWrite + ?Sized>(&self, mut write: Pin<&mut W>) -> io::Result<()> {
write.write_all(HOST_INTRO).await?;
self.log_strategy.encode(write.as_mut()).await?;
self.msg_logs.encode(write.as_mut()).await
self.logger.encode(write.as_mut()).await
}
}
@@ -159,19 +154,19 @@ impl MsgSet for HostMsgSet {
#[cfg(test)]
mod tests {
use std::collections::HashMap;
use orchid_api_traits::enc_vec;
use ordered_float::NotNan;
use test_executors::spin_on;
use super::*;
use crate::Logger;
#[test]
fn host_header_enc() {
spin_on(async {
let hh = HostHeader {
log_strategy: logging::LogStrategy::File("SomeFile".to_string()),
msg_logs: logging::LogStrategy::File("SomeFile".to_string()),
};
let hh = HostHeader { logger: Logger { routing: HashMap::new(), default: None } };
let mut enc = &enc_vec(&hh)[..];
eprintln!("Encoded to {enc:?}");
HostHeader::decode(Pin::new(&mut enc)).await.unwrap();