Method refactor now compiles

This commit is contained in:
2026-01-29 16:28:57 +01:00
parent 534f08b45c
commit cdcca694c5
22 changed files with 487 additions and 284 deletions

View File

@@ -3,10 +3,14 @@ use std::rc::{Rc, Weak};
use async_once_cell::OnceCell;
use derive_destructure::destructure;
#[cfg(feature = "orchid-extension")]
use orchid_api_traits::{Request, UnderRoot};
use orchid_base::format::{FmtCtx, FmtUnit, Format, take_first_fmt};
use orchid_base::location::Pos;
use orchid_base::reqnot::ClientExt;
use orchid_base::tree::AtomRepr;
#[cfg(feature = "orchid-extension")]
use orchid_extension::atom::AtomMethod;
use crate::api;
use crate::ctx::Ctx;
@@ -56,6 +60,21 @@ impl AtomHand {
Self(Rc::new(AtomData { owner, drop, data, display: OnceCell::new() }))
}
#[must_use]
#[cfg(feature = "orchid-extension")]
pub async fn ipc<M: Request + UnderRoot<Root: AtomMethod>>(
&self,
method: M,
) -> Option<M::Response> {
use orchid_api_traits::{Decode, Encode};
use orchid_base::name::Sym;
let name = Sym::parse(<M as UnderRoot>::Root::NAME).await.unwrap();
let mut buf = Vec::new();
method.into_root().encode_vec(&mut buf);
let reply_buf = self.req(name.to_api(), buf).await?;
Some(M::Response::decode_slice(&mut &reply_buf[..]))
}
#[must_use]
pub async fn call(self, arg: Expr) -> Expr {
let owner_sys = self.0.owner.clone();
let ctx = owner_sys.ctx();