Struct worker::durable::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
impl ObjectNamespace
sourcepub fn id_from_name(&self, name: &str) -> Result<ObjectId<'_>>
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.
sourcepub fn id_from_string(&self, hex_id: &str) -> Result<ObjectId<'_>>
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.
sourcepub fn unique_id(&self) -> Result<ObjectId<'_>>
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.
sourcepub fn unique_id_with_jurisdiction(&self, jd: &str) -> Result<ObjectId<'_>>
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/workers/runtime-apis/durable-objects#restricting-objects-to-a-jurisdiction
Trait Implementations§
source§impl AsRef<JsValue> for ObjectNamespace
impl AsRef<JsValue> for ObjectNamespace
source§impl EnvBinding for ObjectNamespace
impl EnvBinding for ObjectNamespace
source§impl From<ObjectNamespace> for JsValue
impl From<ObjectNamespace> for JsValue
source§fn from(ns: ObjectNamespace) -> Self
fn from(ns: ObjectNamespace) -> Self
source§impl JsCast for ObjectNamespace
impl JsCast for ObjectNamespace
source§fn instanceof(val: &JsValue) -> bool
fn instanceof(val: &JsValue) -> bool
instanceof
check to see whether the JsValue
provided is an instance of this type. Read moresource§fn unchecked_from_js(val: JsValue) -> Self
fn unchecked_from_js(val: JsValue) -> Self
source§fn unchecked_from_js_ref(val: &JsValue) -> &Self
fn unchecked_from_js_ref(val: &JsValue) -> &Self
source§fn has_type<T>(&self) -> boolwhere
T: JsCast,
fn has_type<T>(&self) -> boolwhere
T: JsCast,
T
. Read moresource§fn dyn_into<T>(self) -> Result<T, Self>where
T: JsCast,
fn dyn_into<T>(self) -> Result<T, Self>where
T: JsCast,
T
. Read moresource§fn dyn_ref<T>(&self) -> Option<&T>where
T: JsCast,
fn dyn_ref<T>(&self) -> Option<&T>where
T: JsCast,
T
. Read more