Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7afbf74

Browse files
committed
AddMaybeSend bound to async methods onObjectLike trait (sealed)
1 parent06c3bd9 commit7afbf74

File tree

3 files changed

+50
-20
lines changed

3 files changed

+50
-20
lines changed

‎src/table.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ use crate::util::{assert_stack, check_stack, get_metatable_ptr, StackGuard};
1313
usecrate::value::{Nil,Value};
1414

1515
#[cfg(feature ="async")]
16-
use futures_util::future::{self,Either,Future};
16+
use{
17+
crate::types::MaybeSend,
18+
futures_util::future::{self,Either,Future},
19+
};
1720

1821
#[cfg(feature ="serde")]
1922
use{
@@ -889,9 +892,9 @@ impl ObjectLike for Table {
889892

890893
#[cfg(feature ="async")]
891894
#[inline]
892-
fncall_async<R>(&self,args:implIntoLuaMulti) ->implFuture<Output =Result<R>>
895+
fncall_async<R>(&self,args:implIntoLuaMulti) ->implFuture<Output =Result<R>> +MaybeSend
893896
where
894-
R:FromLuaMulti,
897+
R:FromLuaMulti +MaybeSend,
895898
{
896899
Function(self.0.copy()).call_async(args)
897900
}
@@ -905,9 +908,13 @@ impl ObjectLike for Table {
905908
}
906909

907910
#[cfg(feature ="async")]
908-
fncall_async_method<R>(&self,name:&str,args:implIntoLuaMulti) ->implFuture<Output =Result<R>>
911+
fncall_async_method<R>(
912+
&self,
913+
name:&str,
914+
args:implIntoLuaMulti,
915+
) ->implFuture<Output =Result<R>> +MaybeSend
909916
where
910-
R:FromLuaMulti,
917+
R:FromLuaMulti +MaybeSend,
911918
{
912919
self.call_async_function(name,(self, args))
913920
}
@@ -925,9 +932,13 @@ impl ObjectLike for Table {
925932

926933
#[cfg(feature ="async")]
927934
#[inline]
928-
fncall_async_function<R>(&self,name:&str,args:implIntoLuaMulti) ->implFuture<Output =Result<R>>
935+
fncall_async_function<R>(
936+
&self,
937+
name:&str,
938+
args:implIntoLuaMulti,
939+
) ->implFuture<Output =Result<R>> +MaybeSend
929940
where
930-
R:FromLuaMulti,
941+
R:FromLuaMulti +MaybeSend,
931942
{
932943
matchself.get(name){
933944
Ok(Value::Function(func)) =>Either::Left(func.call_async(args)),

‎src/traits.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ pub trait ObjectLike: Sealed {
162162
/// arguments.
163163
#[cfg(feature ="async")]
164164
#[cfg_attr(docsrs, doc(cfg(feature ="async")))]
165-
fncall_async<R>(&self,args:implIntoLuaMulti) ->implFuture<Output =Result<R>>
165+
fncall_async<R>(&self,args:implIntoLuaMulti) ->implFuture<Output =Result<R>> +MaybeSend
166166
where
167-
R:FromLuaMulti;
167+
R:FromLuaMulti +MaybeSend;
168168

169169
/// Gets the function associated to key `name` from the object and calls it,
170170
/// passing the object itself along with `args` as function arguments.
@@ -178,9 +178,13 @@ pub trait ObjectLike: Sealed {
178178
/// This might invoke the `__index` metamethod.
179179
#[cfg(feature ="async")]
180180
#[cfg_attr(docsrs, doc(cfg(feature ="async")))]
181-
fncall_async_method<R>(&self,name:&str,args:implIntoLuaMulti) ->implFuture<Output =Result<R>>
181+
fncall_async_method<R>(
182+
&self,
183+
name:&str,
184+
args:implIntoLuaMulti,
185+
) ->implFuture<Output =Result<R>> +MaybeSend
182186
where
183-
R:FromLuaMulti;
187+
R:FromLuaMulti +MaybeSend;
184188

185189
/// Gets the function associated to key `name` from the object and calls it,
186190
/// passing `args` as function arguments.
@@ -196,9 +200,13 @@ pub trait ObjectLike: Sealed {
196200
/// This might invoke the `__index` metamethod.
197201
#[cfg(feature ="async")]
198202
#[cfg_attr(docsrs, doc(cfg(feature ="async")))]
199-
fncall_async_function<R>(&self,name:&str,args:implIntoLuaMulti) ->implFuture<Output =Result<R>>
203+
fncall_async_function<R>(
204+
&self,
205+
name:&str,
206+
args:implIntoLuaMulti,
207+
) ->implFuture<Output =Result<R>> +MaybeSend
200208
where
201-
R:FromLuaMulti;
209+
R:FromLuaMulti +MaybeSend;
202210

203211
/// Converts the object to a string in a human-readable format.
204212
///

‎src/userdata/object.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ use crate::value::Value;
88
usecrate::Function;
99

1010
#[cfg(feature ="async")]
11-
use futures_util::future::{self,Either,Future};
11+
use{
12+
crate::types::MaybeSend,
13+
futures_util::future::{self,Either,Future},
14+
};
1215

1316
implObjectLikeforAnyUserData{
1417
#[inline]
@@ -35,9 +38,9 @@ impl ObjectLike for AnyUserData {
3538

3639
#[cfg(feature ="async")]
3740
#[inline]
38-
fncall_async<R>(&self,args:implIntoLuaMulti) ->implFuture<Output =Result<R>>
41+
fncall_async<R>(&self,args:implIntoLuaMulti) ->implFuture<Output =Result<R>> +MaybeSend
3942
where
40-
R:FromLuaMulti,
43+
R:FromLuaMulti +MaybeSend,
4144
{
4245
Function(self.0.copy()).call_async(args)
4346
}
@@ -51,9 +54,13 @@ impl ObjectLike for AnyUserData {
5154
}
5255

5356
#[cfg(feature ="async")]
54-
fncall_async_method<R>(&self,name:&str,args:implIntoLuaMulti) ->implFuture<Output =Result<R>>
57+
fncall_async_method<R>(
58+
&self,
59+
name:&str,
60+
args:implIntoLuaMulti,
61+
) ->implFuture<Output =Result<R>> +MaybeSend
5562
where
56-
R:FromLuaMulti,
63+
R:FromLuaMulti +MaybeSend,
5764
{
5865
self.call_async_function(name,(self, args))
5966
}
@@ -72,9 +79,13 @@ impl ObjectLike for AnyUserData {
7279
}
7380

7481
#[cfg(feature ="async")]
75-
fncall_async_function<R>(&self,name:&str,args:implIntoLuaMulti) ->implFuture<Output =Result<R>>
82+
fncall_async_function<R>(
83+
&self,
84+
name:&str,
85+
args:implIntoLuaMulti,
86+
) ->implFuture<Output =Result<R>> +MaybeSend
7687
where
77-
R:FromLuaMulti,
88+
R:FromLuaMulti +MaybeSend,
7889
{
7990
matchself.get(name){
8091
Ok(Value::Function(func)) =>Either::Left(func.call_async(args)),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp