Skip to content

Commit

Permalink
try to support v11 for app side
Browse files Browse the repository at this point in the history
  • Loading branch information
Itsusinn committed May 3, 2022
1 parent 042add1 commit e3f1017
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/app/bot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ use std::time::Duration;
macro_rules! action_api {
($fn_name: ident,$action_ty:ident,$content:ident) => {
pub async fn $fn_name(&self) -> WalleResult<R> {
self.call_action_resp(StandardAction::$action_ty($content::default()).into()).await
self.call_action_resp(StandardAction::$action_ty($content::default()).try_into()?).await
}
};
($fn_name: ident,$action_ty:ident,$content:ident, $field_name: ident: $field_ty: ty) => {
pub async fn $fn_name(&self, $field_name: $field_ty, extra: ExtendedMap) -> WalleResult<R> {
self.call_action_resp(StandardAction::$action_ty($content{
$field_name, extra
}).into()).await
}).try_into()?).await
}
};
($fn_name: ident,$action_ty:ident,$content:ident, $($field_name: ident: $field_ty: ty),*) => {
pub async fn $fn_name(&self, $($field_name: $field_ty,)* extra: ExtendedMap) -> WalleResult<R> {
self.call_action_resp(StandardAction::$action_ty($content{
$($field_name,)* extra
}).into()).await
}).try_into()?).await
}
};
}
Expand All @@ -33,7 +33,8 @@ impl<A, R> super::Bot<A, R> {

impl<A, R> super::Bot<A, R>
where
A: ProtocolItem + From<StandardAction> + Clone + Send + 'static + Debug,
A: ProtocolItem + TryFrom<StandardAction> + Clone + Send + 'static,
WalleError: From<<A as TryFrom<StandardAction>>::Error>,
R: ProtocolItem + Clone + Send + 'static + Debug,
{
pub async fn call_action_resp(&self, action: A) -> WalleResult<R> {
Expand Down
2 changes: 1 addition & 1 deletion walle-v11/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod action;
pub mod app;
mod event;
pub mod event;
mod handle;
pub mod impls;
mod message;
Expand Down
5 changes: 5 additions & 0 deletions walle-v11/src/parse/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ pub enum WalleParseError {
#[error("{0}")]
Other(String),
}
impl From<WalleParseError> for walle_core::WalleError {
fn from(_: WalleParseError) -> Self {
todo!()
}
}

0 comments on commit e3f1017

Please sign in to comment.