Skip to main content

ApiVisibilityComparison

Struct ApiVisibilityComparison 

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

One host-paired API visibility comparison.

This contract is intentionally atomic. The host must compare the same logical resource under the declared views before constructing it; the rule engine never combines independent UI, API, or principal observations. Context and scope identifiers must be opaque, non-secret handles. Raw credentials, tokens, URLs, response values, and resource names do not belong in this contract or its resulting evidence.

§Examples

use termivar_core::{
    ApiSurfaceKind, ApiVisibilityComparison, ApiVisibilityDimension,
    ApiVisibilityPairKind, ApiVisibilityResult, ConfidenceScore,
};

let comparison = ApiVisibilityComparison::new(
    "comparison-17",
    ApiSurfaceKind::JsonHttp,
    ApiVisibilityPairKind::AuthorizationContext,
    ApiVisibilityResult::Different,
    ApiVisibilityDimension::Fields,
    "anonymous-context",
    "member-context",
    "account-resource",
)?;
let observation = comparison.to_observation("host.api-comparator", ConfidenceScore::MAX)?;
let evidence = observation.evidence();

assert!(evidence.subject().as_str().starts_with("api-comparison:"));
assert_eq!(evidence.source().correlation_id(), Some(evidence.subject().as_str()));
assert_eq!(observation.scope_relation().to(), observation.resource_scope());

Implementations§

Source§

impl ApiVisibilityComparison

Source

pub fn new( comparison_id: impl Into<String>, surface: ApiSurfaceKind, pair: ApiVisibilityPairKind, result: ApiVisibilityResult, dimension: ApiVisibilityDimension, baseline_context_id: impl Into<String>, candidate_context_id: impl Into<String>, resource_scope_id: impl Into<String>, ) -> Result<Self, ApiVocabularyError>

Creates one validated, already-paired observation.

Source

pub fn new_typed( comparison_id: ComparisonId, surface: ApiSurfaceKind, pair: ApiVisibilityPairKind, result: ApiVisibilityResult, dimension: ApiVisibilityDimension, baseline_context_id: OpaqueContextId, candidate_context_id: OpaqueContextId, resource_scope_id: ResourceScopeId, ) -> Result<Self, ApiVocabularyError>

Creates one already-validated paired observation from typed identifiers.

The baseline and candidate remain checked here because individually valid context identifiers must still represent distinct views.

Source

pub fn comparison_id(&self) -> &str

Returns the opaque host comparison identifier.

Source

pub const fn typed_comparison_id(&self) -> &ComparisonId

Returns the typed opaque host comparison identifier.

Source

pub const fn baseline_context_id(&self) -> &OpaqueContextId

Returns the typed opaque baseline context identifier.

Source

pub const fn candidate_context_id(&self) -> &OpaqueContextId

Returns the typed opaque candidate context identifier.

Source

pub const fn resource_scope_id(&self) -> &ResourceScopeId

Returns the typed opaque resource-scope identifier.

Source

pub const fn surface(&self) -> ApiSurfaceKind

Returns the API surface that was compared.

Source

pub const fn pair(&self) -> ApiVisibilityPairKind

Returns the pair of views that was compared.

Source

pub const fn result(&self) -> ApiVisibilityResult

Returns the paired comparison result.

Source

pub const fn dimension(&self) -> ApiVisibilityDimension

Returns the measured visibility dimension.

Source

pub const fn observed_at_ms(&self) -> u64

Returns when the host constructed this paired observation.

Source

pub fn with_observed_at_ms(self, observed_at_ms: u64) -> Self

Replaces the observation time for deterministic replay or import.

Source

pub fn subject(&self) -> EntityId

Returns a raw-value-free, stable entity ID unique to this comparison.

This SHA-256 identity is pseudonymous, not a cryptographic attestation; hosts should supply non-secret, suitably opaque context handles.

Source

pub fn resource_scope(&self) -> EntityId

Returns the opaque resource entity that the host compared.

Source

pub fn to_observation( &self, component: impl Into<String>, reliability: ConfidenceScore, ) -> Result<ApiVisibilityObservation, ApiVocabularyError>

Emits the evidence and a stable evidence-backed resource-scope edge.

Source

pub fn to_evidence( &self, component: impl Into<String>, reliability: ConfidenceScore, ) -> Result<Evidence, ApiVocabularyError>

Emits a detached immutable evidence record for this comparison.

The source correlation and subject use the same digest, so separate principals or comparison turns cannot contaminate one another. Prefer Self::to_observation for durable storage; callers using this lower- level method must persist an equivalent resource mapping themselves.

Trait Implementations§

Source§

impl Clone for ApiVisibilityComparison

Source§

fn clone(&self) -> ApiVisibilityComparison

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ApiVisibilityComparison

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ApiVisibilityComparison

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for ApiVisibilityComparison

Source§

impl PartialEq for ApiVisibilityComparison

Source§

fn eq(&self, other: &ApiVisibilityComparison) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ApiVisibilityComparison

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ApiVisibilityComparison

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.