#[non_exhaustive]pub struct PresentationV2 {
pub context: Context,
pub id: Option<Uri>,
pub types: OneOrMany<String>,
pub holder: Option<Party>,
pub verifiable_credential: Vec<EnvelopedVc>,
pub properties: IndexMap<String, Value>,
}vc only.Expand description
A verifiable presentation of the Verifiable Credentials Data Model 2.0 whose credentials
are EnvelopedVc objects, as data.
Secured per VC-JOSE-COSE, the presentation itself is the JWT payload, with typ: vp+jwt
in the header; the holder signs it.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.context: Context@context, starting with PresentationV2::CONTEXT.
id: Option<Uri>The identifier of the presentation.
types: OneOrMany<String>type, including PresentationV2::TYPE.
holder: Option<Party>The holder presenting the credentials.
verifiable_credential: Vec<EnvelopedVc>The presented credentials, each enveloped.
properties: IndexMap<String, Value>Every other property, in insertion order.
Implementations§
Source§impl PresentationV2
impl PresentationV2
pub fn serialize<__S>(
__self: &PresentationV2,
__serializer: __S,
) -> Result<__S::Ok, __S::Error>where
__S: Serializer,
Source§impl<'de> PresentationV2
impl<'de> PresentationV2
pub fn deserialize<__D>(
__deserializer: __D,
) -> Result<PresentationV2, __D::Error>where
__D: Deserializer<'de>,
Source§impl PresentationV2
impl PresentationV2
Sourcepub const CONTEXT: &'static str = CONTEXT_V2
pub const CONTEXT: &'static str = CONTEXT_V2
The base context, https://www.w3.org/ns/credentials/v2.
Sourcepub const TYPE: &'static str = "VerifiablePresentation"
pub const TYPE: &'static str = "VerifiablePresentation"
The type every presentation has, VerifiablePresentation.
Sourcepub const JWT_MEDIA_TYPE: &'static str = "application/vp+jwt"
pub const JWT_MEDIA_TYPE: &'static str = "application/vp+jwt"
The media type of a JWT securing a presentation, application/vp+jwt.
Sourcepub fn with_context(self, context: impl Into<String>) -> Self
pub fn with_context(self, context: impl Into<String>) -> Self
This presentation with context appended to its @context.
Sourcepub fn with_type(self, presentation_type: impl Into<String>) -> Self
pub fn with_type(self, presentation_type: impl Into<String>) -> Self
This presentation with presentation_type appended to its type.
Sourcepub fn with_holder(self, holder: impl Into<Party>) -> Self
pub fn with_holder(self, holder: impl Into<Party>) -> Self
This presentation with its holder set.
Sourcepub fn with_credential(self, credential: EnvelopedVc) -> Self
pub fn with_credential(self, credential: EnvelopedVc) -> Self
This presentation with credential added.
Sourcepub fn with_property(
self,
name: impl Into<String>,
value: impl Into<Value>,
) -> Self
pub fn with_property( self, name: impl Into<String>, value: impl Into<Value>, ) -> Self
This presentation with the property name set to value.
Sourcepub fn has_type(&self, presentation_type: &str) -> bool
pub fn has_type(&self, presentation_type: &str) -> bool
Whether presentation_type is among the types.
Sourcepub fn check(&self) -> Result<(), CredentialError>
pub fn check(&self) -> Result<(), CredentialError>
Checks that the first @context is the base context and type includes
VerifiablePresentation.
§Errors
The first CredentialError found.
Sourcepub fn to_jwt_claims(&self) -> JwtClaims
pub fn to_jwt_claims(&self) -> JwtClaims
The JWT claims set securing the presentation (VC-JOSE-COSE §3.1.2): the presentation’s
own properties. iss, aud, nonce and the rest are the caller’s to add.
Sourcepub fn from_jwt_claims(jwt_claims: &JwtClaims) -> Result<Self, CredentialError>
pub fn from_jwt_claims(jwt_claims: &JwtClaims) -> Result<Self, CredentialError>
The presentation a JWT claims set secures, with iss and jti, when present, checked
against holder and id.
§Errors
Trait Implementations§
Source§impl Clone for PresentationV2
impl Clone for PresentationV2
Source§impl Debug for PresentationV2
impl Debug for PresentationV2
Source§impl Default for PresentationV2
impl Default for PresentationV2
Source§impl<'de> Deserialize<'de> for PresentationV2
impl<'de> Deserialize<'de> for PresentationV2
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Reads the presentation and checks it with PresentationV2::check.
impl Eq for PresentationV2
Source§impl PartialEq for PresentationV2
impl PartialEq for PresentationV2
Source§impl Serialize for PresentationV2
impl Serialize for PresentationV2
impl StructuralPartialEq for PresentationV2
Auto Trait Implementations§
impl Freeze for PresentationV2
impl RefUnwindSafe for PresentationV2
impl Send for PresentationV2
impl Sync for PresentationV2
impl Unpin for PresentationV2
impl UnsafeUnpin for PresentationV2
impl UnwindSafe for PresentationV2
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.