File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
worker-sys/src/types/durable_object Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -34,4 +34,11 @@ extern "C" {
3434 this : & DurableObjectNamespace ,
3535 id : & DurableObjectId ,
3636 ) -> 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 > ;
3744}
Original file line number Diff line number Diff line change @@ -155,6 +155,24 @@ impl ObjectId<'_> {
155155 } )
156156 . map_err ( Error :: from)
157157 }
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+ }
158176}
159177
160178impl Display for ObjectId < ' _ > {
You can’t perform that action at this time.
0 commit comments