pub struct Proxy<O> { /* private fields */ }
Expand description
A wrapper around a worker::Stub
that provides a builder interface for
sending requests. This is the only way to send requests to a durable object
in a type-safe way.
Create proxies using the crate::EnvExt
trait.
The Builder
type returned by Proxy::send
and Proxy::init
implements std::future::IntoFuture
. This means, you must use .await
to
actually send the request.
Implementations
sourceimpl<O: DoProxy> Proxy<O>
impl<O: DoProxy> Proxy<O>
sourcepub fn send(&self, request: O::Request) -> Builder<'_, O, Send>
pub fn send(&self, request: O::Request) -> Builder<'_, O, Send>
Send a request to the durable object. You must await this future to
Example
ⓘ
let resp = proxy.send(Command::GetBirthday).await?;
sourcepub fn init(&self, init: O::Init) -> Builder<'_, O, WithInit>
pub fn init(&self, init: O::Init) -> Builder<'_, O, WithInit>
Send a request to the durable object. You can immediately await
the
result of this method to initialize the object, or you can chain a
.and_send()
call to have the object handle a request after it is
initialized.
Example
ⓘ
// Initialize a person object, no response is expected.
proxy.init(Person::new("Bob")).await?;
// or
let resp = proxy.init(Person::new("Bob")).and_send(Command::GetBirthday).await?;
Auto Trait Implementations
impl<O> RefUnwindSafe for Proxy<O>where
O: RefUnwindSafe,
impl<O> !Send for Proxy<O>
impl<O> !Sync for Proxy<O>
impl<O> Unpin for Proxy<O>where
O: Unpin,
impl<O> UnwindSafe for Proxy<O>where
O: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more