dimas_core::traits

Trait ContextAbstraction

Source
pub trait ContextAbstraction:
    Debug
    + Send
    + Sync {
    type Props;

Show 22 methods // Required methods fn name(&self) -> Option<&String>; fn fq_name(&self) -> Option<String>; fn state(&self) -> OperationState; fn set_state(&self, state: OperationState) -> Result<()>; fn uuid(&self) -> String; fn prefix(&self) -> Option<&String>; fn mode(&self) -> &String; fn default_session(&self) -> Arc<Session>; fn session(&self, session_id: &str) -> Option<Arc<Session>>; fn sender(&self) -> &Sender<TaskSignal>; fn read(&self) -> Result<RwLockReadGuard<'_, Self::Props>>; fn write(&self) -> Result<RwLockWriteGuard<'_, Self::Props>>; fn put_with(&self, selector: &str, message: Message) -> Result<()>; fn delete_with(&self, selector: &str) -> Result<()>; fn get_with( &self, selector: &str, message: Option<Message>, callback: Option<&mut dyn FnMut(QueryableMsg) -> Result<()>>, ) -> Result<()>; fn observe_with( &self, selector: &str, message: Option<Message>, ) -> Result<()>; fn cancel_observe_with(&self, selector: &str) -> Result<()>; // Provided methods fn put(&self, topic: &str, message: Message) -> Result<()> { ... } fn delete(&self, topic: &str) -> Result<()> { ... } fn get( &self, topic: &str, message: Option<Message>, callback: Option<&mut dyn FnMut(QueryableMsg) -> Result<()>>, ) -> Result<()> { ... } fn observe(&self, topic: &str, message: Option<Message>) -> Result<()> { ... } fn cancel_observe(&self, topic: &str) -> Result<()> { ... }
}
Expand description

Commonalities for the context

Required Associated Types§

Source

type Props

The properties structure

Required Methods§

Source

fn name(&self) -> Option<&String>

Get the name

Source

fn fq_name(&self) -> Option<String>

Get the fully qualified name

Source

fn state(&self) -> OperationState

Get the Contexts state

§Panics
Source

fn set_state(&self, state: OperationState) -> Result<()>

Set the OperationState.
Setting new state is done step by step

§Errors
Source

fn uuid(&self) -> String

Get the uuid

Source

fn prefix(&self) -> Option<&String>

Get prefix

Source

fn mode(&self) -> &String

Get session mode

Source

fn default_session(&self) -> Arc<Session>

Get default session reference

Source

fn session(&self, session_id: &str) -> Option<Arc<Session>>

Get session reference

Source

fn sender(&self) -> &Sender<TaskSignal>

Get sender reference

Source

fn read(&self) -> Result<RwLockReadGuard<'_, Self::Props>>

Gives read access to the properties

§Errors
Source

fn write(&self) -> Result<RwLockWriteGuard<'_, Self::Props>>

Gives write access to the properties

§Errors
Source

fn put_with(&self, selector: &str, message: Message) -> Result<()>

Method to do a publishing for a selector If there is a publisher stored, it will be used otherwise an ad-hoc publishing will be done

§Errors
Source

fn delete_with(&self, selector: &str) -> Result<()>

Method to do a deletion for a selector If there is a publisher stored, it will be used otherwise an ad-hoc deletion will be done

§Errors
Source

fn get_with( &self, selector: &str, message: Option<Message>, callback: Option<&mut dyn FnMut(QueryableMsg) -> Result<()>>, ) -> Result<()>

Send a query for a selector with an optional Message. The topic will be enhanced with the prefix. If there is a query stored, it will be used otherwise an ad-hoc query will be done If a callback is given for a stored query, it will be called instead of the stored callback

§Errors
Source

fn observe_with(&self, selector: &str, message: Option<Message>) -> Result<()>

Send an observation request for a selector with a Message.

§Errors
Source

fn cancel_observe_with(&self, selector: &str) -> Result<()>

Cancel an observation request for a selector.

§Errors

Provided Methods§

Source

fn put(&self, topic: &str, message: Message) -> Result<()>

Method to do a publishing for a topic The topic will be enhanced with the prefix. If there is a publisher stored, it will be used otherwise an ad-hoc publishing will be done

§Errors
Source

fn delete(&self, topic: &str) -> Result<()>

Method to do a deletion for a topic The topic will be enhanced with the prefix. If there is a publisher stored, it will be used otherwise an ad-hoc deletion will be done

§Errors
Source

fn get( &self, topic: &str, message: Option<Message>, callback: Option<&mut dyn FnMut(QueryableMsg) -> Result<()>>, ) -> Result<()>

Send a query for a topic with an optional Message. The topic will be enhanced with the prefix. If there is a query stored, it will be used otherwise an ad-hoc query will be done If a callback is given for a stored query, it will be called instead of the stored callback

§Errors
Source

fn observe(&self, topic: &str, message: Option<Message>) -> Result<()>

Send an observation request for a topic with a Message. The topic will be enhanced with the prefix.

§Errors
Source

fn cancel_observe(&self, topic: &str) -> Result<()>

Cancel an observation request for a topic. The topic will be enhanced with the prefix.

§Errors

Implementors§