File tree 2 files changed +25
-0
lines changed
worker-sys/src/types/durable_object
2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -34,4 +34,11 @@ extern "C" {
34
34
this : & DurableObjectNamespace ,
35
35
id : & DurableObjectId ,
36
36
) -> Result < DurableObject , JsValue > ;
37
+
38
+ #[ wasm_bindgen( method, catch, js_name=get) ]
39
+ pub fn get_with_options (
40
+ this : & DurableObjectNamespace ,
41
+ id : & DurableObjectId ,
42
+ options : & JsValue ,
43
+ ) -> Result < DurableObject , JsValue > ;
37
44
}
Original file line number Diff line number Diff line change @@ -155,6 +155,24 @@ impl ObjectId<'_> {
155
155
} )
156
156
. map_err ( Error :: from)
157
157
}
158
+
159
+ pub fn get_stub_with_location_hint ( & self , location_hint : & str ) -> Result < Stub > {
160
+ let options = Object :: new ( ) ;
161
+ js_sys:: Reflect :: set (
162
+ & options,
163
+ & JsValue :: from ( "locationHint" ) ,
164
+ & location_hint. into ( ) ,
165
+ ) ?;
166
+
167
+ self . namespace
168
+ . ok_or_else ( || JsValue :: from ( "Cannot get stub from within a Durable Object" ) )
169
+ . and_then ( |n| {
170
+ Ok ( Stub {
171
+ inner : n. inner . get_with_options ( & self . inner , & options) ?,
172
+ } )
173
+ } )
174
+ . map_err ( Error :: from)
175
+ }
158
176
}
159
177
160
178
impl Display for ObjectId < ' _ > {
You can’t perform that action at this time.
0 commit comments