Skip to main content

Response

Struct Response 

Source
pub struct Response<'a> { /* private fields */ }
Expand description

Complete DER response and its original optional token. Private fields keep the status/token association immutable; reading establishes no trust.

use std::sync::Arc;
use structured_asn1::{Parser, memory::{Memory, MemoryAccount}};
use structured_cms::timestamp::{Response, response::Status};
let memory = Memory::new(Arc::new(MemoryAccount::new(4096, 65536)));
let parser = Parser::der(memory);
let mut reader = parser.read(&[0x30, 5, 0x30, 3, 2, 1, 2], 400).unwrap();
let response = Response::read(&mut reader).unwrap();
assert_eq!(response.status().status(), Status::Rejection);
assert!(response.token().is_none()); // no signature evidence on failure

Implementations§

Source§

impl<'doc> Response<'doc>

Source

pub fn check<'a, P, S: Source, PE, RE>( &'a self, provider: &'a P, query: &Reader<'a>, context: &CheckContext<'a, '_>, covered: &mut S, recognizes: impl FnMut(&TokenExtension<'_>, &Execution<'_>) -> Result<bool, RE>, ) -> Result<CheckedResponse<'a>, CheckError<S::Error, PE, RE>>
where P: for<'scope> SignatureProvider<'scope, Error = PE>, 'doc: 'a,

Check a response against its actual live parsed request. context.requested is required; its absence is a caller-context InvalidLocation refusal, not a malformed response or a downgrade to archival checking. Negative status responses start no provider, profile, recognizer or covered-content work. All token, request, source, callback and resource causes remain unchanged.

Source

pub fn check_with_profile<'a, P, S: Source, PE, RE, FE>( &'a self, provider: &'a P, query: &Reader<'a>, context: &CheckContext<'a, '_>, covered: &mut S, recognizes: impl FnMut(&TokenExtension<'_>, &Execution<'_>) -> Result<bool, RE>, profile: impl for<'view, 'scope> FnOnce(ProfileInput<'view, 'doc, 'a, 'scope>) -> Result<(), ProfileFailure<FE>>, ) -> Result<CheckedResponse<'a>, ProfileCheckError<S::Error, PE, RE, FE>>
where P: for<'scope> SignatureProvider<'scope, Error = PE>, 'doc: 'a,

Same shared token kernel with its original pre-crypto profile hook. No response status, nonce or certificate hint bypasses the selected profile.

Source§

impl<'a> Response<'a>

Source

pub fn read(parent: &mut Reader<'a>) -> Result<Self>

Read exactly one complete response; refuse any trailing source bytes.

Source

pub fn read_element(parent: &Reader<'a>, element: &Element<'a>) -> Result<Self>

Read one original embedded response. The response’s own DER contract applies even in a BER carrier, without a replacement parser or account.

Source

pub fn status(&self) -> &StatusInfo<'a>

Original unauthenticated status metadata.

Source

pub fn token(&self) -> Option<&Token<'a>>

Original token, only present for granted/grantedWithMods.

Source

pub fn element(&self) -> &Element<'a>

Original whole response; no re-encoded token or physical-offset reset.

Source

pub fn token_reader_in<'op>( &self, query: &Reader<'op>, ) -> Result<Option<Reader<'op>>>
where 'a: 'op,

Reopen the actual token at its original nested depth and current/source ceilings. Absence is paid metadata, not an unlimited lookup fast path.

Trait Implementations§

Source§

impl<'a> Debug for Response<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !Freeze for Response<'a>

§

impl<'a> !RefUnwindSafe for Response<'a>

§

impl<'a> !Send for Response<'a>

§

impl<'a> !Sync for Response<'a>

§

impl<'a> !UnwindSafe for Response<'a>

§

impl<'a> Unpin for Response<'a>

§

impl<'a> UnsafeUnpin for Response<'a>

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.