Trait tor_rpcbase::Context
source · pub trait Context: Send {
// Required methods
fn lookup_object(
&self,
id: &ObjectId
) -> Result<Arc<dyn Object>, LookupError>;
fn register_owned(&self, object: Arc<dyn Object>) -> ObjectId;
fn register_weak(&self, object: Arc<dyn Object>) -> ObjectId;
fn release_owned(&self, object: &ObjectId) -> Result<(), LookupError>;
}Expand description
A trait describing the context in which an RPC method is executed.
Required Methods§
sourcefn lookup_object(&self, id: &ObjectId) -> Result<Arc<dyn Object>, LookupError>
fn lookup_object(&self, id: &ObjectId) -> Result<Arc<dyn Object>, LookupError>
Look up an object by identity within this context.
sourcefn register_owned(&self, object: Arc<dyn Object>) -> ObjectId
fn register_owned(&self, object: Arc<dyn Object>) -> ObjectId
Create an owning reference to object within this context.
Return an ObjectId for this object.
TODO RPC: We may need to change the above semantics and the name of this function depending on how we decide to name and specify things.
sourcefn register_weak(&self, object: Arc<dyn Object>) -> ObjectId
fn register_weak(&self, object: Arc<dyn Object>) -> ObjectId
Make sure that
this context contains a non-owning reference to object,
creating one if necessary.
Return an ObjectId for this object.
Note that this takes an Arc, since that’s required in order to find a working type Id for the target object.
TODO RPC: We may need to change the above semantics and the name of this function depending on how we decide to name and specify things.
sourcefn release_owned(&self, object: &ObjectId) -> Result<(), LookupError>
fn release_owned(&self, object: &ObjectId) -> Result<(), LookupError>
Drop an owning reference to the object called object within this context.
This will return an error if object is not an owning reference.
TODO RPC should this really return a LookupError?