[go: up one dir, main page]

worker::durable

Struct ObjectNamespace

source
pub struct ObjectNamespace { /* private fields */ }
Expand description

Use an ObjectNamespace to get access to Stubs for communication with a Durable Object instance. A given namespace can support essentially unlimited Durable Objects, with each Object having access to a transactional, key-value storage API.

Implementations§

source§

impl ObjectNamespace

source

pub fn id_from_name(&self, name: &str) -> Result<ObjectId<'_>>

This method derives a unique object ID from the given name string. It will always return the same ID when given the same name as input.

source

pub fn id_from_string(&self, hex_id: &str) -> Result<ObjectId<'_>>

This method parses an ID that was previously stringified. This is useful in particular with IDs created using unique_id(&self), as these IDs need to be stored somewhere, probably as

A stringified object ID is a 64-digit hexadecimal number. However, not all 64-digit hex numbers are valid IDs. This method will throw if it is passed an ID that was not originally created by newUniqueId() or idFromName(). It will also throw if the ID was originally created for a different namespace.

source

pub fn unique_id(&self) -> Result<ObjectId<'_>>

Creates a new object ID randomly. This method will never return the same ID twice, and thus it is guaranteed that the object does not yet exist and has never existed at the time the method returns.

source

pub fn unique_id_with_jurisdiction(&self, jd: &str) -> Result<ObjectId<'_>>

Durable Objects can be created so that they only run and store data within a specific jurisdiction to comply with local regulations. You must specify the jurisdiction when generating the Durable Object’s id.

Jurisdiction constraints can only be used with ids created by unique_id() and are not currently compatible with ids created by id_from_name().

See supported jurisdictions and more documentation at: https://developers.cloudflare.com/durable-objects/reference/data-location/#restrict-durable-objects-to-a-jurisdiction

Trait Implementations§

source§

impl AsRef<JsValue> for ObjectNamespace

source§

fn as_ref(&self) -> &JsValue

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for ObjectNamespace

source§

fn clone(&self) -> ObjectNamespace

Returns a copy of the value. Read more
1.6.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl EnvBinding for ObjectNamespace

source§

const TYPE_NAME: &'static str = "DurableObjectNamespace"

source§

fn get(val: JsValue) -> Result<Self>

source§

impl From<ObjectNamespace> for JsValue

source§

fn from(ns: ObjectNamespace) -> Self

Converts to this type from the input type.
source§

impl JsCast for ObjectNamespace

source§

fn instanceof(val: &JsValue) -> bool

Performs a dynamic instanceof check to see whether the JsValue provided is an instance of this type. Read more
source§

fn unchecked_from_js(val: JsValue) -> Self

Performs a zero-cost unchecked conversion from a JsValue into an instance of Self Read more
source§

fn unchecked_from_js_ref(val: &JsValue) -> &Self

Performs a zero-cost unchecked conversion from a &JsValue into an instance of &Self. Read more
source§

fn has_type<T>(&self) -> bool
where T: JsCast,

Test whether this JS value has a type T. Read more
source§

fn dyn_into<T>(self) -> Result<T, Self>
where T: JsCast,

Performs a dynamic cast (checked at runtime) of this value into the target type T. Read more
source§

fn dyn_ref<T>(&self) -> Option<&T>
where T: JsCast,

Performs a dynamic cast (checked at runtime) of this value into the target type T. Read more
source§

fn unchecked_into<T>(self) -> T
where T: JsCast,

Performs a zero-cost unchecked cast into the specified type. Read more
source§

fn unchecked_ref<T>(&self) -> &T
where T: JsCast,

Performs a zero-cost unchecked cast into a reference to the specified type. Read more
source§

fn is_instance_of<T>(&self) -> bool
where T: JsCast,

Test whether this JS value is an instance of the type T. Read more
source§

fn is_type_of(val: &JsValue) -> bool

Performs a dynamic check to see whether the JsValue provided is a value of this type. Read more
source§

impl Send for ObjectNamespace

source§

impl Sync for ObjectNamespace

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromRef<T> for T
where T: Clone,

source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V