pub struct FetcherTransport { /* private fields */ }Expand description
ClientTransport backed by a Workers service binding.
Construct with Self::new. Cloning is cheap because the underlying
Fetcher is just a JsValue handle.
Implementations§
Source§impl FetcherTransport
impl FetcherTransport
pub fn new(fetcher: Fetcher) -> Self
Sourcepub fn from_stub(stub: Stub) -> Self
pub fn from_stub(stub: Stub) -> Self
Create a transport from a Durable Object Stub.
In the Workers runtime a DurableObjectStub extends Fetcher, so
the underlying JS object supports the same fetch() API. This
method casts the stub to a Fetcher via Stub::into_rpc and
wraps it in a FetcherTransport.
ⓘ
let ns = env.durable_object("MY_DO")?;
let stub = ns.get_by_name("instance-1")?;
let transport = FetcherTransport::from_stub(stub);
let config = ClientConfig::new("http://my-do/".parse()?);
let client = MyServiceClient::new(transport, config);Trait Implementations§
Source§impl ClientTransport for FetcherTransport
impl ClientTransport for FetcherTransport
Source§impl Clone for FetcherTransport
impl Clone for FetcherTransport
Source§fn clone(&self) -> FetcherTransport
fn clone(&self) -> FetcherTransport
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for FetcherTransport
impl RefUnwindSafe for FetcherTransport
impl Send for FetcherTransport
impl Sync for FetcherTransport
impl Unpin for FetcherTransport
impl UnsafeUnpin for FetcherTransport
impl UnwindSafe for FetcherTransport
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more