Skip to main content

TaskRouting

Trait TaskRouting 

Source
pub trait TaskRouting: Send + Sync {
    // Required methods
    fn model_for(&self, task: &str) -> Arc<dyn Model> ⓘ;
    fn model_name_for(&self, task: &str) -> Option<String>;
    fn resolve_model(&self, name: &str) -> String;
    fn observe(&self, observer: Arc<dyn RouteObserver>);
    fn starting_at(
        &self,
        provider: &str,
    ) -> Result<Arc<dyn TaskRouting>, String>;
    fn in_order(&self, provider: &str) -> bool;
    fn home_of(&self, model: &str) -> Option<String>;
    fn destination(&self, task: &str, model: &str) -> Destination;
}
Expand description

Where a session’s model calls go: the model each kind of call goes through, and what a model or tier name stands for at the provider calls go to first.

Required Methods§

Source

fn model_for(&self, task: &str) -> Arc<dyn Model> ⓘ

The model task’s calls go through. A task with no tier of its own asks for strong.

Source

fn model_name_for(&self, task: &str) -> Option<String>

The model task goes to at the head of the order; None for a task that uses no model.

Source

fn resolve_model(&self, name: &str) -> String

The model name stands for at the head: its model of that tier when name is a tier, else name.

Source

fn observe(&self, observer: Arc<dyn RouteObserver>)

Report this session’s provider switches to observer. The first observer stays.

Source

fn starting_at(&self, provider: &str) -> Result<Arc<dyn TaskRouting>, String>

A route of its own over the same providers: provider first, the rest in this route’s order, with its own record of where its calls went and its own observer. Err when provider is not defined.

Source

fn in_order(&self, provider: &str) -> bool

Whether provider is in this route’s order.

Source

fn home_of(&self, model: &str) -> Option<String>

The first provider in the order that lists model or names it as a tier. One that only accepts any model is no home.

Source

fn destination(&self, task: &str, model: &str) -> Destination

Where task’s call asking for model goes while the head can take it; an empty model asks for the task’s tier.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§