Compiles again after command subsystem

terrified to start testing
This commit is contained in:
2026-03-27 23:50:58 +01:00
parent 09cfcb1839
commit 0909524dee
75 changed files with 1165 additions and 609 deletions

View File

@@ -1,4 +1,5 @@
use std::borrow::Cow;
use std::io;
use std::time::Instant;
use chrono::TimeDelta;
@@ -6,13 +7,14 @@ use never::Never;
use orchid_api::ExprTicket;
use orchid_api_derive::{Coding, Hierarchy};
use orchid_api_traits::Request;
use orchid_base::{Numeric, OrcRes};
use orchid_extension::conv::{ToExpr, TryFromExpr};
use orchid_extension::expr::Expr;
use orchid_base::{Numeric, OrcRes, Receipt, ReqHandle, ReqHandleExt};
use orchid_extension::gen_expr::{GExpr, call, new_atom};
use orchid_extension::system::sys_req;
use orchid_extension::std_reqs::{AsDuration, RunCommand};
use orchid_extension::tree::{GenMember, fun, prefix};
use orchid_extension::{Atomic, OwnedAtom, OwnedVariant, TAtom, ThinAtom, ThinVariant};
use orchid_extension::{
Atomic, Expr, MethodSetBuilder, OwnedAtom, OwnedVariant, Supports, TAtom, ThinAtom, ThinVariant,
ToExpr, TryFromExpr, sys_req,
};
use ordered_float::NotNan;
use crate::std::std_system::StdReq;
@@ -42,6 +44,15 @@ impl TryFromExpr for OrcDT {
Ok(TAtom::<OrcDT>::try_from_expr(expr).await?.value)
}
}
impl Supports<AsDuration> for OrcDT {
async fn handle<'a>(
&self,
hand: Box<dyn ReqHandle<'a> + '_>,
req: AsDuration,
) -> std::io::Result<Receipt<'a>> {
hand.reply(&req, &self.0.to_std().unwrap()).await
}
}
#[derive(Clone)]
pub struct InstantAtom(Instant);
@@ -59,12 +70,20 @@ struct Now(Expr);
impl Atomic for Now {
type Variant = OwnedVariant;
type Data = ();
fn reg_methods() -> MethodSetBuilder<Self> { MethodSetBuilder::new().handle::<RunCommand>() }
}
impl OwnedAtom for Now {
type Refs = Never;
async fn val(&self) -> Cow<'_, Self::Data> { Cow::Owned(()) }
async fn command(self) -> OrcRes<Option<GExpr>> {
Ok(Some(call(self.0, new_atom(InstantAtom(Instant::now())))))
}
impl Supports<RunCommand> for Now {
async fn handle<'a>(
&self,
hand: Box<dyn ReqHandle<'a> + '_>,
req: RunCommand,
) -> io::Result<Receipt<'a>> {
let cont = call(self.0.clone(), new_atom(InstantAtom(Instant::now()))).await.serialize().await;
hand.reply(&req, &Some(cont)).await
}
}