Skip to main content

ObservationAudience

Trait ObservationAudience 

Source
pub trait ObservationAudience: Send + Sync {
    // Required methods
    fn audience<'life0, 'life1, 'async_trait>(
        &'life0 self,
        partition: &'life1 PartitionId,
    ) -> Pin<Box<dyn Future<Output = Result<Option<(SubjectRef, PartitionMode)>, KernelError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn confirm<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        item: &'life1 AgendaItem,
        by: &'life2 SubjectRef,
    ) -> Pin<Box<dyn Future<Output = Result<String, KernelError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             Self: 'async_trait;
}
Available on crate feature harness-kernel only.
Expand description

Whom a partition’s observations are put to, and where a confirmed one is remembered (spec 3.2 §7.10, spec 3.1 §7.15): the kernel reads no harness type, so the harness implements this over its long-term memory (adk_harness::Harness::observation_audience) and registers it with KernelBuilder::observation_audience.

The daily baseline pass (feature proc-baselines) files each observation of a partition with an audience as an AgendaOrigin::Observation item: titled with the question, its rationale the factual statement the person confirms. A partition without one keeps its observations at /api/kernel/proc/observations and puts no question to anyone.

§Example

use adk_core::principal::SubjectRef;
use adk_kernel::{AgendaItem, ObservationAudience, PartitionId, PartitionMode};

struct Alice;

#[async_trait::async_trait]
impl ObservationAudience for Alice {
    async fn audience(&self, _: &PartitionId) -> adk_kernel::Result<Option<(SubjectRef, PartitionMode)>> {
        Ok(Some((SubjectRef::human("alice"), PartitionMode::Ask)))
    }
    async fn confirm(&self, item: &AgendaItem, _by: &SubjectRef) -> adk_kernel::Result<String> {
        Ok(format!("fact-for-{}", item.id))
    }
}

Required Methods§

Source

fn audience<'life0, 'life1, 'async_trait>( &'life0 self, partition: &'life1 PartitionId, ) -> Pin<Box<dyn Future<Output = Result<Option<(SubjectRef, PartitionMode)>, KernelError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

The person partition’s observations are put to and the partition’s mode now; None puts them to nobody.

§Errors

Returns the error that kept the audience from answering; the observation stays recorded and no item is filed.

Source

fn confirm<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, item: &'life1 AgendaItem, by: &'life2 SubjectRef, ) -> Pin<Box<dyn Future<Output = Result<String, KernelError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Records that the person by confirmed item: its rationale, the observation’s statement, becomes a Known fact of item.subject with the person as its source. Returns the fact’s id.

§Errors

Returns the error that kept the fact from being recorded; the item stays Proposed.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§