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
impl EvidenceSession
Sourcepub fn try_new(
project: Project,
snapshots: impl IntoIterator<Item = SourceSnapshot>,
) -> Result<Self, EvidenceSessionError>
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.
Sourcepub fn federate(
members: impl IntoIterator<Item = EvidenceSession>,
) -> Result<Self, EvidenceSessionError>
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.
Sourcepub fn with_discipline(
self,
source: &SourceId,
discipline: Discipline,
) -> Result<Self, EvidenceSessionError>
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.
Sourcepub fn discipline(&self, source: &SourceId) -> Option<&Discipline>
pub fn discipline(&self, source: &SourceId) -> Option<&Discipline>
The discipline declared for source, if any.
Sourcepub fn disciplines(&self) -> &BTreeMap<SourceId, Discipline>
pub fn disciplines(&self) -> &BTreeMap<SourceId, Discipline>
Every declared discipline, by source.
Sourcepub fn with_discipline_map(self, map: &DisciplineMap) -> Self
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.
Sourcepub fn discipline_origin(&self, source: &SourceId) -> Option<&DisciplineOrigin>
pub fn discipline_origin(&self, source: &SourceId) -> Option<&DisciplineOrigin>
Where source’s discipline came from, if it has one.
Sourcepub fn unmapped(&self, source: &SourceId) -> Option<&UnmappedReason>
pub fn unmapped(&self, source: &SourceId) -> Option<&UnmappedReason>
Why a discipline map left source without a discipline, if one did.
Sourcepub fn with_source_metadata(
self,
source: &SourceId,
metadata: SourceMetadata,
) -> Result<Self, EvidenceSessionError>
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.
Sourcepub fn source_metadata(&self, source: &SourceId) -> Option<&SourceMetadata>
pub fn source_metadata(&self, source: &SourceId) -> Option<&SourceMetadata>
Everything stated about source as a whole, if anything.
Sourcepub fn with_service<T: SnapshotBoundService>(
self,
service: T,
) -> Result<Self, EvidenceSessionError>
pub fn with_service<T: SnapshotBoundService>( self, service: T, ) -> Result<Self, EvidenceSessionError>
Registers one non-replaceable typed evidence service.
Sourcepub fn with_host_service<T: Any + Send + Sync>(
self,
service: T,
built_from: &[SourceSnapshot],
) -> Result<Self, EvidenceSessionError>
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.
Sourcepub fn with_derived_relationships(
self,
service: DerivedRelationshipServiceHandle,
built_from: &[SourceSnapshot],
) -> Result<Self, EvidenceSessionError>
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.
Sourcepub fn snapshots(&self) -> impl ExactSizeIterator<Item = &SourceSnapshot>
pub fn snapshots(&self) -> impl ExactSizeIterator<Item = &SourceSnapshot>
Returns all immutable source identities bound to the project.
Sourcepub fn snapshot(&self, source: &SourceId) -> Option<&SourceSnapshot>
pub fn snapshot(&self, source: &SourceId) -> Option<&SourceSnapshot>
Returns one source snapshot identity.
Sourcepub fn services(&self) -> &ServiceRegistry
pub fn services(&self) -> &ServiceRegistry
Returns all services bound to this snapshot.