terrified to start testing
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
use std::rc::Rc;
|
||||
|
||||
use orchid_base::{OrcErrv, is, mk_errv};
|
||||
use orchid_extension::TAtom;
|
||||
use orchid_extension::func_atom::get_arg_posv;
|
||||
use orchid_extension::gen_expr::new_atom;
|
||||
use orchid_extension::tree::{GenMember, comments, fun, prefix};
|
||||
use orchid_extension::{TAtom, get_arg_posv};
|
||||
|
||||
use crate::std::binary::binary_atom::BlobAtom;
|
||||
use crate::std::boolean::Bool;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use orchid_api_derive::Coding;
|
||||
use orchid_base::{FmtUnit, OrcRes, sym};
|
||||
use orchid_extension::conv::{ToExpr, TryFromExpr};
|
||||
use orchid_extension::expr::Expr;
|
||||
use orchid_extension::{ToExpr, TryFromExpr};
|
||||
use orchid_extension::Expr;
|
||||
use orchid_extension::gen_expr::GExpr;
|
||||
use orchid_extension::tree::{GenMember, cnst, comments, fun, prefix};
|
||||
use orchid_extension::{Atomic, TAtom, ThinAtom, ThinVariant};
|
||||
|
||||
@@ -19,15 +19,14 @@ use never::Never;
|
||||
use orchid_api_derive::{Coding, Hierarchy};
|
||||
use orchid_api_traits::Request;
|
||||
use orchid_base::{FmtCtxImpl, OrcRes};
|
||||
use orchid_extension::conv::ToExpr;
|
||||
use orchid_extension::ToExpr;
|
||||
use orchid_extension::entrypoint::spawn;
|
||||
use orchid_extension::expr::Expr;
|
||||
use orchid_extension::Expr;
|
||||
use orchid_extension::gen_expr::{GExpr, IntoGExprStream, call, new_atom};
|
||||
use orchid_extension::system::cted;
|
||||
use orchid_extension::tree::{GenMember, cnst, comments, fun, prefix};
|
||||
use orchid_extension::{
|
||||
Atomic, CmdResult, Continuation, ForeignAtom, Next, OwnedAtom, OwnedVariant, err_not_callable,
|
||||
err_not_command,
|
||||
Atomic, ForeignAtom, OwnedAtom, OwnedVariant, err_not_callable, err_not_command,
|
||||
};
|
||||
use rust_decimal::prelude::Zero;
|
||||
use tokio::task::{JoinHandle, spawn_local};
|
||||
|
||||
@@ -1 +1 @@
|
||||
pub mod future_lib;
|
||||
// pub mod future_lib;
|
||||
|
||||
@@ -3,10 +3,10 @@ use std::io;
|
||||
use orchid_api_derive::{Coding, Hierarchy};
|
||||
use orchid_api_traits::Request;
|
||||
use orchid_base::{FmtUnit, Numeric, OrcRes, Receipt, ReqHandle, ReqHandleExt, Sym, sym};
|
||||
use orchid_extension::conv::{ToExpr, TryFromExpr};
|
||||
use orchid_extension::expr::Expr;
|
||||
use orchid_extension::system::sys_req;
|
||||
use orchid_extension::{Atomic, MethodSetBuilder, Supports, TAtom, ThinAtom, ThinVariant};
|
||||
use orchid_extension::{
|
||||
Atomic, Expr, MethodSetBuilder, Supports, TAtom, ThinAtom, ThinVariant, ToExpr, TryFromExpr,
|
||||
sys_req,
|
||||
};
|
||||
use ordered_float::NotNan;
|
||||
use rust_decimal::prelude::Zero;
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use std::ops::RangeInclusive;
|
||||
|
||||
use orchid_base::{OrcRes, num_to_errv, parse_num};
|
||||
use orchid_extension::conv::ToExpr;
|
||||
use orchid_extension::lexer::{LexContext, Lexer};
|
||||
use orchid_extension::tree::{GenTokTree, x_tok};
|
||||
use orchid_extension::{LexContext, Lexer};
|
||||
|
||||
use super::num_atom::Num;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use orchid_base::{Numeric, is, mk_errv};
|
||||
use orchid_extension::func_atom::get_arg;
|
||||
use orchid_extension::get_arg;
|
||||
use orchid_extension::tree::{GenMember, fun, prefix};
|
||||
use ordered_float::NotNan;
|
||||
use rust_decimal::prelude::ToPrimitive;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use orchid_base::{name_char, name_start};
|
||||
use orchid_base::{OrcRes, is};
|
||||
use orchid_extension::gen_expr::new_atom;
|
||||
use orchid_extension::lexer::{LexContext, LexedData, Lexer, err_not_applicable};
|
||||
use orchid_extension::{LexContext, LexedData, Lexer, err_not_applicable};
|
||||
use orchid_extension::tree::GenTok;
|
||||
|
||||
use crate::std::string::str_atom::IntStrAtom;
|
||||
|
||||
@@ -4,8 +4,8 @@ use std::pin::Pin;
|
||||
use futures::AsyncWrite;
|
||||
use orchid_api_traits::Encode;
|
||||
use orchid_base::{is, mk_errv, sym};
|
||||
use orchid_extension::conv::{ToExpr, TryFromExpr};
|
||||
use orchid_extension::expr::{Expr, ExprHandle};
|
||||
use orchid_extension::{ToExpr, TryFromExpr};
|
||||
use orchid_extension::{Expr, ExprHandle};
|
||||
use orchid_extension::gen_expr::{call, new_atom};
|
||||
use orchid_extension::tree::{GenMember, cnst, fun, prefix};
|
||||
use orchid_extension::{Atomic, DeserializeCtx, ForeignAtom, OwnedAtom, OwnedVariant, TAtom};
|
||||
|
||||
@@ -5,7 +5,7 @@ use orchid_base::{
|
||||
};
|
||||
use orchid_base::{Paren, Token};
|
||||
use orchid_base::{IStr, OrcRes, is, mk_errv};
|
||||
use orchid_extension::parser::{
|
||||
use orchid_extension::{
|
||||
PTokTree, ParsCtx, ParsedLine, ParsedLineKind, p_tree2gen, p_v2gen,
|
||||
};
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ use std::rc::Rc;
|
||||
|
||||
use hashbrown::HashMap;
|
||||
use orchid_base::{Comment, OrcRes, Parsed, Token, expect_end, is, mk_errv, sym, try_pop_no_fluff};
|
||||
use orchid_extension::conv::ToExpr;
|
||||
use orchid_extension::ToExpr;
|
||||
use orchid_extension::gen_expr::{call, new_atom};
|
||||
use orchid_extension::parser::{PSnippet, ParsCtx, ParsedLine, Parser};
|
||||
use orchid_extension::{PSnippet, ParsCtx, ParsedLine, Parser};
|
||||
|
||||
use crate::std::protocol::parse_impls::parse_impls;
|
||||
use crate::std::protocol::types::Tag;
|
||||
|
||||
@@ -2,9 +2,9 @@ use std::rc::Rc;
|
||||
|
||||
use hashbrown::HashMap;
|
||||
use orchid_base::{Comment, OrcRes, Parsed, Token, expect_end, is, mk_errv, sym, try_pop_no_fluff};
|
||||
use orchid_extension::conv::ToExpr;
|
||||
use orchid_extension::ToExpr;
|
||||
use orchid_extension::gen_expr::{call, new_atom};
|
||||
use orchid_extension::parser::{PSnippet, ParsCtx, ParsedLine, Parser};
|
||||
use orchid_extension::{PSnippet, ParsCtx, ParsedLine, Parser};
|
||||
|
||||
use crate::std::protocol::parse_impls::parse_impls;
|
||||
use crate::std::protocol::types::Tag;
|
||||
|
||||
@@ -11,14 +11,11 @@ use never::Never;
|
||||
use orchid_api_derive::{Coding, Hierarchy};
|
||||
use orchid_api_traits::Request;
|
||||
use orchid_base::{NameLike, OrcRes, ReqHandleExt, Sym, VName, ev, fmt, is, mk_errv};
|
||||
use orchid_extension::conv::{ClonableToExprDyn, ToExpr};
|
||||
use orchid_extension::coroutine_exec::exec;
|
||||
use orchid_extension::expr::{Expr, ExprHandle};
|
||||
use orchid_extension::gen_expr::{GExpr, call, new_atom};
|
||||
use orchid_extension::system::sys_req;
|
||||
use orchid_extension::tree::{GenMember, MemKind, cnst, fun, lazy, prefix};
|
||||
use orchid_extension::{
|
||||
AtomMethod, Atomic, ForeignAtom, MethodSetBuilder, OwnedAtom, OwnedVariant, Supports, TAtom,
|
||||
AtomMethod, Atomic, ClonableToExprDyn, Expr, ExprHandle, ForeignAtom, MethodSetBuilder,
|
||||
OwnedAtom, OwnedVariant, Supports, TAtom, ToExpr, exec, sys_req,
|
||||
};
|
||||
|
||||
use crate::std::std_system::StdReq;
|
||||
|
||||
@@ -9,8 +9,8 @@ use hashbrown::HashMap;
|
||||
use orchid_api_derive::Coding;
|
||||
use orchid_api_traits::{Encode, Request};
|
||||
use orchid_base::{IStr, Receipt, ReqHandle, ReqHandleExt, Sym, es, sym};
|
||||
use orchid_extension::conv::ToExpr;
|
||||
use orchid_extension::expr::Expr;
|
||||
use orchid_extension::ToExpr;
|
||||
use orchid_extension::Expr;
|
||||
use orchid_extension::{
|
||||
Atomic, DeserializeCtx, MethodSetBuilder, OwnedAtom, OwnedVariant, Supports,
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@ use hashbrown::HashMap;
|
||||
use itertools::Itertools;
|
||||
use orchid_base::{is, mk_errv};
|
||||
use orchid_extension::TAtom;
|
||||
use orchid_extension::expr::Expr;
|
||||
use orchid_extension::Expr;
|
||||
use orchid_extension::gen_expr::{arg, new_atom};
|
||||
use orchid_extension::tree::{GenMember, cnst, fun, prefix};
|
||||
|
||||
|
||||
@@ -3,12 +3,11 @@ use std::borrow::Cow;
|
||||
use orchid_api_derive::{Coding, Hierarchy};
|
||||
use orchid_api_traits::Request;
|
||||
use orchid_base::{NameLike, ReqHandleExt, Sym, es, is, mk_errv};
|
||||
use orchid_extension::{Atomic, Supports, TAtom};
|
||||
use orchid_extension::{OwnedAtom, OwnedVariant};
|
||||
use orchid_extension::expr::{Expr, ExprHandle};
|
||||
use orchid_extension::gen_expr::new_atom;
|
||||
use orchid_extension::system::sys_req;
|
||||
use orchid_extension::tree::{GenMember, fun, prefix};
|
||||
use orchid_extension::{
|
||||
Atomic, Expr, ExprHandle, OwnedAtom, OwnedVariant, Supports, TAtom, sys_req,
|
||||
};
|
||||
|
||||
use crate::std::std_system::StdReq;
|
||||
use crate::std::string::str_atom::IntStrAtom;
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
use std::cell::OnceCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
use futures::future::join_all;
|
||||
use orchid_api_derive::{Coding, Hierarchy};
|
||||
use orchid_base::{Receipt, ReqHandle, ReqHandleExt, Sym, es, sym};
|
||||
use orchid_extension::{AtomOps, AtomicFeatures};
|
||||
use orchid_extension::conv::ToExpr;
|
||||
use orchid_extension::expr::Expr;
|
||||
use orchid_extension::gen_expr::new_atom;
|
||||
use orchid_extension::lexer::LexerObj;
|
||||
use orchid_extension::parser::ParserObj;
|
||||
use orchid_extension::system::{System, SystemCard};
|
||||
use orchid_extension::system_ctor::SystemCtor;
|
||||
use orchid_extension::ParserObj;
|
||||
use orchid_extension::tree::{GenMember, merge_trivial};
|
||||
use orchid_extension::{
|
||||
AtomOps, AtomicFeatures, Expr, LexerObj, ReqForSystem, System, SystemCard, SystemCtor, ToExpr,
|
||||
};
|
||||
|
||||
use super::number::num_lib::gen_num_lib;
|
||||
use super::string::str_atom::{IntStrAtom, StrAtom};
|
||||
@@ -20,7 +16,6 @@ use super::string::str_lib::gen_str_lib;
|
||||
use crate::std::binary::binary_atom::BlobAtom;
|
||||
use crate::std::binary::binary_lib::gen_binary_lib;
|
||||
use crate::std::boolean::gen_bool_lib;
|
||||
use crate::std::future::future_lib::{FutureReq, Scheduler, gen_future_lib};
|
||||
use crate::std::number::num_atom::{CreateFloat, CreateInt};
|
||||
use crate::std::number::num_lexer::NumLexer;
|
||||
use crate::std::ops::gen_ops_lib;
|
||||
@@ -49,19 +44,17 @@ pub enum StdReq {
|
||||
CreateTuple(CreateTuple),
|
||||
CreateRecord(CreateRecord),
|
||||
CreateSymAtom(CreateSymAtom),
|
||||
FutureReq(FutureReq),
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct StdSystem {
|
||||
pub(crate) sched: OnceCell<Scheduler>,
|
||||
}
|
||||
pub struct StdSystem;
|
||||
impl SystemCtor for StdSystem {
|
||||
type Deps = ();
|
||||
type Card = Self;
|
||||
type Instance = Self;
|
||||
const NAME: &'static str = "orchid::std";
|
||||
const VERSION: f64 = 0.00_01;
|
||||
fn inst(&self, _: ()) -> Self::Instance { Self::default() }
|
||||
fn inst(&self, _: ()) -> Self::Instance { Self }
|
||||
}
|
||||
impl SystemCard for StdSystem {
|
||||
type Ctor = Self;
|
||||
@@ -83,16 +76,13 @@ impl SystemCard for StdSystem {
|
||||
}
|
||||
}
|
||||
impl System for StdSystem {
|
||||
async fn request<'a>(&self, xreq: Box<dyn ReqHandle<'a> + 'a>, req: Self::Req) -> Receipt<'a> {
|
||||
type Ctor = Self;
|
||||
async fn request<'a>(
|
||||
&self,
|
||||
xreq: Box<dyn ReqHandle<'a> + 'a>,
|
||||
req: ReqForSystem<Self>,
|
||||
) -> Receipt<'a> {
|
||||
match req {
|
||||
StdReq::FutureReq(req) => {
|
||||
let sched = self.sched.get_or_init(Scheduler::default);
|
||||
match req {
|
||||
FutureReq::AddAsyncWork(req) => xreq.reply(&req, &sched.add(&req).await).await.unwrap(),
|
||||
FutureReq::FinishAsyncWork(req) =>
|
||||
xreq.reply(&req, &sched.finish(&req).await).await.unwrap(),
|
||||
}
|
||||
},
|
||||
StdReq::CreateInt(ref req @ CreateInt(int)) =>
|
||||
xreq.reply(req, &new_atom(int).to_expr().await.serialize().await).await.unwrap(),
|
||||
StdReq::CreateFloat(ref req @ CreateFloat(float)) =>
|
||||
@@ -151,7 +141,6 @@ impl System for StdSystem {
|
||||
gen_binary_lib(),
|
||||
gen_stream_lib(),
|
||||
gen_time_lib(),
|
||||
gen_future_lib(),
|
||||
])
|
||||
}
|
||||
async fn prelude(&self) -> Vec<Sym> {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
use std::borrow::Cow;
|
||||
use std::io;
|
||||
use std::rc::Rc;
|
||||
|
||||
use never::Never;
|
||||
use orchid_base::{OrcRes, fmt, is, mk_errv};
|
||||
use orchid_extension::expr::Expr;
|
||||
use orchid_extension::gen_expr::{GExpr, bot, call, new_atom};
|
||||
use orchid_extension::stream_reqs::{ReadLimit, ReadReq};
|
||||
use orchid_extension::{Atomic, ForeignAtom, OwnedAtom, OwnedVariant};
|
||||
use orchid_base::{ReqHandleExt, fmt, is, mk_errv};
|
||||
use orchid_extension::gen_expr::{bot, call, new_atom};
|
||||
use orchid_extension::std_reqs::{ReadLimit, ReadReq, RunCommand};
|
||||
use orchid_extension::{Atomic, Expr, ForeignAtom, OwnedAtom, OwnedVariant, Supports, ToExpr};
|
||||
|
||||
use crate::std::binary::binary_atom::BlobAtom;
|
||||
|
||||
@@ -24,16 +24,22 @@ impl Atomic for ReadStreamCmd {
|
||||
impl OwnedAtom for ReadStreamCmd {
|
||||
type Refs = Never;
|
||||
async fn val(&self) -> Cow<'_, Self::Data> { Cow::Owned(()) }
|
||||
async fn command(self) -> OrcRes<Option<GExpr>> {
|
||||
match self.hand.call(ReadReq(self.limit)).await {
|
||||
}
|
||||
impl Supports<RunCommand> for ReadStreamCmd {
|
||||
async fn handle<'a>(
|
||||
&self,
|
||||
hand: Box<dyn orchid_base::ReqHandle<'a> + '_>,
|
||||
req: RunCommand,
|
||||
) -> io::Result<orchid_base::Receipt<'a>> {
|
||||
let ret = match self.hand.call(ReadReq(self.limit.clone())).await {
|
||||
None => Err(mk_errv(
|
||||
is("Atom is not readable").await,
|
||||
format!("Expected a readable stream handle, found {}", fmt(&self.hand).await),
|
||||
[self.hand.pos()],
|
||||
)),
|
||||
Some(Err(e)) => Ok(Some(
|
||||
Some(Err(e)) => Ok(
|
||||
call(
|
||||
self.fail,
|
||||
self.fail.clone(),
|
||||
bot(mk_errv(
|
||||
is(e.kind.message()).await,
|
||||
format!("An error occurred while reading: {}", e.message),
|
||||
@@ -41,8 +47,9 @@ impl OwnedAtom for ReadStreamCmd {
|
||||
)),
|
||||
)
|
||||
.await,
|
||||
)),
|
||||
Some(Ok(v)) => Ok(Some(call(self.succ, new_atom(BlobAtom(Rc::new(v)))).await)),
|
||||
}
|
||||
),
|
||||
Some(Ok(v)) => Ok(call(self.succ.clone(), new_atom(BlobAtom(Rc::new(v)))).await),
|
||||
};
|
||||
hand.reply(&req, &Some(ret.to_gen().await.serialize().await)).await
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
use std::num::NonZero;
|
||||
use std::rc::Rc;
|
||||
|
||||
use orchid_base::{is, mk_errv};
|
||||
use orchid_extension::ForeignAtom;
|
||||
use orchid_extension::expr::Expr;
|
||||
use orchid_extension::func_atom::get_arg;
|
||||
use orchid_extension::gen_expr::new_atom;
|
||||
use orchid_extension::stream_reqs::ReadLimit;
|
||||
use orchid_extension::gen_expr::{call, new_atom};
|
||||
use orchid_extension::std_reqs::ReadLimit;
|
||||
use orchid_extension::tree::{GenMember, comments, fun, prefix};
|
||||
use orchid_extension::{Expr, ForeignAtom, get_arg};
|
||||
|
||||
use crate::Int;
|
||||
use crate::std::binary::binary_atom::BlobAtom;
|
||||
use crate::std::stream::stream_cmds::ReadStreamCmd;
|
||||
|
||||
pub fn gen_stream_lib() -> Vec<GenMember> {
|
||||
@@ -30,7 +32,16 @@ pub fn gen_stream_lib() -> Vec<GenMember> {
|
||||
Ok(new_atom(ReadStreamCmd { hand, succ, fail, limit: ReadLimit::Delimiter(end) }))
|
||||
}),
|
||||
fun(true, "read_bytes", async |hand: ForeignAtom, count: Int, succ: Expr, fail: Expr| {
|
||||
Int(todo!())
|
||||
match count.0.try_into().map(NonZero::new) {
|
||||
Ok(Some(nzlen)) =>
|
||||
Ok(new_atom(ReadStreamCmd { hand, succ, fail, limit: ReadLimit::Length(nzlen) })),
|
||||
Ok(None) => Ok(call(succ, new_atom(BlobAtom(Rc::default()))).await),
|
||||
Err(_) => Err(mk_errv(
|
||||
is("Length cannot be negative").await,
|
||||
format!("{} is negative and cannot be used as a length", count.0),
|
||||
[get_arg(1).pos().await],
|
||||
)),
|
||||
}
|
||||
}),
|
||||
]),
|
||||
)])
|
||||
|
||||
@@ -10,8 +10,8 @@ use orchid_api_traits::{Encode, Request};
|
||||
use orchid_base::{
|
||||
FmtCtx, FmtUnit, IStr, OrcRes, Receipt, ReqHandle, ReqHandleExt, Sym, es, is, mk_errv, sym,
|
||||
};
|
||||
use orchid_extension::conv::{ToExpr, TryFromExpr};
|
||||
use orchid_extension::expr::Expr;
|
||||
use orchid_extension::{ToExpr, TryFromExpr};
|
||||
use orchid_extension::Expr;
|
||||
use orchid_extension::{
|
||||
AtomMethod, Atomic, DeserializeCtx, MethodSetBuilder, OwnedAtom, OwnedVariant, Supports, TAtom,
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use itertools::Itertools;
|
||||
use orchid_base::{OrcErr, OrcErrv, OrcRes, Paren, SrcRange, Sym, is, mk_errv, sym, wrap_tokv};
|
||||
use orchid_extension::conv::ToExpr;
|
||||
use orchid_extension::ToExpr;
|
||||
use orchid_extension::gen_expr::new_atom;
|
||||
use orchid_extension::lexer::{LexContext, Lexer, err_not_applicable};
|
||||
use orchid_extension::parser::p_tree2gen;
|
||||
use orchid_extension::{LexContext, Lexer, err_not_applicable};
|
||||
use orchid_extension::p_tree2gen;
|
||||
use orchid_extension::tree::{GenTok, GenTokTree, ref_tok, x_tok};
|
||||
|
||||
use super::str_atom::IntStrAtom;
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
use std::rc::Rc;
|
||||
|
||||
use orchid_base::{fmt, is, mk_errv, sym};
|
||||
use orchid_extension::ForeignAtom;
|
||||
use orchid_extension::coroutine_exec::exec;
|
||||
use orchid_extension::expr::Expr;
|
||||
use orchid_extension::func_atom::get_arg;
|
||||
use orchid_extension::gen_expr::{call, new_atom};
|
||||
use orchid_extension::tree::{GenMember, comments, fun, prefix};
|
||||
use orchid_extension::{Expr, ForeignAtom, exec, get_arg};
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
||||
use super::str_atom::StrAtom;
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,13 +9,11 @@ use never::Never;
|
||||
use orchid_api_derive::{Coding, Hierarchy};
|
||||
use orchid_api_traits::Request;
|
||||
use orchid_base::{FmtCtx, FmtUnit, Format, OrcRes, ReqHandleExt, Sym, Variants, is, mk_errv, sym};
|
||||
use orchid_extension::conv::{ToExpr, TryFromExpr};
|
||||
use orchid_extension::expr::{Expr, ExprHandle};
|
||||
use orchid_extension::gen_expr::{GExpr, new_atom};
|
||||
use orchid_extension::system::sys_req;
|
||||
use orchid_extension::tree::{GenMember, cnst, fun, prefix};
|
||||
use orchid_extension::{
|
||||
Atomic, DeserializeCtx, MethodSetBuilder, OwnedAtom, OwnedVariant, Supports, TAtom,
|
||||
Atomic, DeserializeCtx, Expr, ExprHandle, MethodSetBuilder, OwnedAtom, OwnedVariant, Supports,
|
||||
TAtom, ToExpr, TryFromExpr, sys_req,
|
||||
};
|
||||
|
||||
use crate::std::protocol::types::{GetImpl, ProtocolMethod};
|
||||
@@ -171,9 +169,8 @@ pub struct Tpl<T>(pub T);
|
||||
mod tpl_impls {
|
||||
use itertools::Itertools;
|
||||
use orchid_base::{OrcRes, is, mk_errv};
|
||||
use orchid_extension::conv::{ToExpr, TryFromExpr};
|
||||
use orchid_extension::expr::Expr;
|
||||
use orchid_extension::gen_expr::GExpr;
|
||||
use orchid_extension::{Expr, ToExpr, TryFromExpr};
|
||||
|
||||
use super::{Tpl, UntypedTuple};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user