Trait tor_rpcbase::Context

source ·
pub trait Context: Send + Sync {
    // 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>;
    fn dispatch_table(&self) -> &Arc<RwLock<DispatchTable>>;
}
Expand description

A trait describing the context in which an RPC method is executed.

Required Methods§

source

fn lookup_object(&self, id: &ObjectId) -> Result<Arc<dyn Object>, LookupError>

Look up an object by identity within this context.

source

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.

source

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.

source

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?

source

fn dispatch_table(&self) -> &Arc<RwLock<DispatchTable>>

Return a dispatch table that can be used to invoke other RPC methods.

Implementors§