Struct worker::RouteContext
source · [−]pub struct RouteContext<D> {
pub data: D,
pub env: Env,
/* private fields */
}
Expand description
Container for a route’s parsed parameters, data, and environment bindings from the Runtime (such as KV Stores, Durable Objects, Variables, and Secrets).
Fields
data: D
env: Env
Implementations
sourceimpl<D> RouteContext<D>
impl<D> RouteContext<D>
sourcepub fn data(&self) -> &D
👎Deprecated since 0.0.8: please use the data
field directly
pub fn data(&self) -> &D
please use the data
field directly
Get a reference to the generic associated data provided to the Router
.
sourcepub fn get_env(self) -> Env
👎Deprecated since 0.0.8: please use the env
field directly
pub fn get_env(self) -> Env
please use the env
field directly
Get the Env
for this Worker. Typically users should opt for the secret
, var
, kv
and
durable_object
methods on the RouteContext
instead.
sourcepub fn secret(&self, binding: &str) -> Result<Secret>
pub fn secret(&self, binding: &str) -> Result<Secret>
Get a Secret value associated with this Worker, should one exist.
sourcepub fn var(&self, binding: &str) -> Result<Var>
pub fn var(&self, binding: &str) -> Result<Var>
Get an Environment Variable value associated with this Worker, should one exist.
sourcepub fn kv(&self, binding: &str) -> Result<KvStore>
pub fn kv(&self, binding: &str) -> Result<KvStore>
Get a KV Namespace associated with this Worker, should one exist.
sourcepub fn durable_object(&self, binding: &str) -> Result<ObjectNamespace>
pub fn durable_object(&self, binding: &str) -> Result<ObjectNamespace>
Get a Durable Object Namespace associated with this Worker, should one exist.
Auto Trait Implementations
impl<D> RefUnwindSafe for RouteContext<D> where
D: RefUnwindSafe,
impl<D> !Send for RouteContext<D>
impl<D> !Sync for RouteContext<D>
impl<D> Unpin for RouteContext<D> where
D: Unpin,
impl<D> UnwindSafe for RouteContext<D> where
D: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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