forked from Orchid/orchid
Method refactor now compiles
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user