Skip to main content

EvidenceSession

Struct EvidenceSession 

Source
pub struct EvidenceSession { /* private fields */ }
Expand description

Immutable project snapshot bound to the exact host services that produced and can resolve its evidence.

Adapters build a session once per source snapshot. Runtime evaluation then consumes the project and services as one unit, preventing accidental use of a resolver from a different model revision.

Implementations§

Source§

impl EvidenceSession

Source

pub fn try_new( project: Project, snapshots: impl IntoIterator<Item = SourceSnapshot>, ) -> Result<Self, EvidenceSessionError>

Starts a session after proving every project source has exactly one snapshot.

A snapshot need not contribute an object: a model holding no objects (only presentation data, or nothing at all) is an empty source and still part of the session. Capabilities that judge each source as a whole find it through SessionSources, so an empty source is reported rather than skipped.

§Errors

Returns an error when two snapshots name the same source, or an object’s source has no snapshot.

Source

pub fn federate( members: impl IntoIterator<Item = EvidenceSession>, ) -> Result<Self, EvidenceSessionError>

Combines sessions over disjoint sources into one session.

The project holds every member’s objects under their own source-qualified identities, and every snapshot and declared discipline is kept, including a member whose source holds no objects, which stays in the session as an empty source. Each semantic service the members registered (property resolution, relationship selection, type hierarchy, object frames, classifications, integrity, resource objects) becomes one service bound to the snapshots of the members that had it, answering each request from the member that owns the request’s source; a source no member covers is refused, never answered empty. A relationship request is answered from its anchor’s member over the part of the candidate universe in that member’s sources, since a member cannot relate objects it does not hold.

One member is returned unchanged. Federate before registering host services such as geometry: they are built over the federated project and bound to all its snapshots.

§Errors

Returns an error when two members hold the same source, or a member holds a service other than the semantic ones above.

Source

pub fn with_discipline( self, source: &SourceId, discipline: Discipline, ) -> Result<Self, EvidenceSessionError>

Declares the discipline source plays in this check.

A discipline is a host declaration, not part of the snapshot identity: services bound to a snapshot stay valid whatever role the source plays. Capabilities read it through crate::SourceDisciplines; the discipline selector matches on it.

§Errors

Returns an error when the session holds no such source or it already declares a discipline.

Source

pub fn discipline(&self, source: &SourceId) -> Option<&Discipline>

The discipline declared for source, if any.

Source

pub fn disciplines(&self) -> &BTreeMap<SourceId, Discipline>

Every declared discipline, by source.

Source

pub fn with_discipline_map(self, map: &DisciplineMap) -> Self

Assigns disciplines from source metadata to the sources that declare none.

Each such source takes the discipline of the first rule of map matching one of its field’s values, and the session records the rule and the value (Self::discipline_origin); the discipline selector cites them. A declared discipline is never replaced. A source no rule matches keeps none, as does one where a rule reads a field it never stated, since that rule might have matched (Self::unmapped). Map after stating metadata and declaring disciplines: a discipline declared afterwards for a mapped source is a duplicate.

Source

pub fn discipline_origin(&self, source: &SourceId) -> Option<&DisciplineOrigin>

Where source’s discipline came from, if it has one.

Source

pub fn unmapped(&self, source: &SourceId) -> Option<&UnmappedReason>

Why a discipline map left source without a discipline, if one did.

Source

pub fn with_source_metadata( self, source: &SourceId, metadata: SourceMetadata, ) -> Result<Self, EvidenceSessionError>

States what is known about source as a whole: the adapter the applications and project it read, the host the file name.

Statements add up field by field; stating a field again with the same values is a no-op. Capabilities read the metadata through crate::SourceMetadataIndex; the source selector matches on it.

§Errors

Returns an error when the session holds no such source, or a field is already stated with other values.

Source

pub fn source_metadata(&self, source: &SourceId) -> Option<&SourceMetadata>

Everything stated about source as a whole, if anything.

Source

pub fn with_service<T: SnapshotBoundService>( self, service: T, ) -> Result<Self, EvidenceSessionError>

Registers one non-replaceable typed evidence service.

Source

pub fn with_host_service<T: Any + Send + Sync>( self, service: T, built_from: &[SourceSnapshot], ) -> Result<Self, EvidenceSessionError>

Registers a host service that records no snapshot of its own.

Some services are built by the host from data it read alongside the session, such as geometry meshed from the same file, and carry only a source identity. The host states which of this session’s snapshots the service was built from, and the same checks as Self::with_service apply: at least one binding, no source twice, and every binding equal to the session’s snapshot for that source. A service built from another revision of a source is refused.

§Errors

Returns an error when a binding is missing, repeated or stale, or a service of this type is already registered.

Source

pub fn with_derived_relationships( self, service: DerivedRelationshipServiceHandle, built_from: &[SourceSnapshot], ) -> Result<Self, EvidenceSessionError>

Registers a derived-relationship service and routes the session’s relationship selection through it.

Afterwards the session’s RelationshipSelectionServiceHandle answers identities starting with crate::DERIVED_RELATIONSHIP_PREFIX from service and every other identity from the semantic service registered before, so capabilities taking a relationship or path use derived relationships unchanged. Register the semantic service first; one registered afterwards is a duplicate. built_from is checked as in Self::with_host_service.

§Errors

Returns an error when a binding is missing, repeated or stale, or a derived-relationship service is already registered.

Source

pub fn project(&self) -> &Project

Returns the immutable project snapshot.

Source

pub fn snapshots(&self) -> impl ExactSizeIterator<Item = &SourceSnapshot>

Returns all immutable source identities bound to the project.

Source

pub fn snapshot(&self, source: &SourceId) -> Option<&SourceSnapshot>

Returns one source snapshot identity.

Source

pub fn services(&self) -> &ServiceRegistry

Returns all services bound to this snapshot.

Source

pub fn service<T: Any + Send + Sync>(&self) -> Option<&T>

Returns one typed service bound to this snapshot.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.