#[non_exhaustive]pub struct EnvelopedVc {
pub context: Context,
pub id: Uri,
pub types: OneOrMany<String>,
}vc only.Expand description
An EnvelopedVerifiableCredential (VCDM 2.0 §4.12.1): a secured credential carried in
a data: URL, the form a credential takes inside a PresentationV2.
§Examples
use identity_kit::vc::{EnvelopedVc, Jwt};
let jwt: Jwt = "eyJhbGciOiJFZERTQSJ9.RXhhbXBsZSBvZiBFZDI1NTE5IHNpZ25pbmc.\
hgyY0il_MGCjP0JzlnLWG1PPOt7-09PGcvMg3AIbQR6dWbhijcNR4ki4iylGjg5BhVsPt9g7sVvpAr_MuM0KAg"
.parse()?;
let enveloped = EnvelopedVc::from_jwt(&jwt);
assert_eq!(enveloped.media_type(), "application/vc+jwt");
assert_eq!(enveloped.to_jwt()?, jwt);
assert_eq!(
serde_json::to_value(&enveloped)?["type"],
"EnvelopedVerifiableCredential"
);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, which must define the type; the base context does.
id: UriThe data: URL holding the secured form.
types: OneOrMany<String>type, including the enveloped type.
Implementations§
Source§impl EnvelopedVc
impl EnvelopedVc
pub fn serialize<__S>(
__self: &EnvelopedVc,
__serializer: __S,
) -> Result<__S::Ok, __S::Error>where
__S: Serializer,
Source§impl<'de> EnvelopedVc
impl<'de> EnvelopedVc
pub fn deserialize<__D>(__deserializer: __D) -> Result<EnvelopedVc, __D::Error>where
__D: Deserializer<'de>,
Source§impl EnvelopedVc
impl EnvelopedVc
Sourcepub const JWT_MEDIA_TYPE: &'static str = CredentialV2::JWT_MEDIA_TYPE
pub const JWT_MEDIA_TYPE: &'static str = CredentialV2::JWT_MEDIA_TYPE
The media type of the JWT form this crate reads.
Sourcepub fn new(media_type: &str, data: &str) -> Result<Self, CredentialError>
pub fn new(media_type: &str, data: &str) -> Result<Self, CredentialError>
An envelope for data of media_type, in the base context.
data is placed in the URL as is; a JWT needs no encoding, other media types
may.
§Errors
CredentialError::InvalidClaim for id when media_type or data holds a
character a URI cannot.
Sourcepub fn media_type(&self) -> &str
pub fn media_type(&self) -> &str
The media type of the data: URL.
Sourcepub fn to_jwt(&self) -> Result<Jwt, CredentialError>
pub fn to_jwt(&self) -> Result<Jwt, CredentialError>
The JWT the envelope holds.
§Errors
CredentialError::UnsupportedMediaType when the media type is not the JWT
one, and CredentialError::InvalidClaim when the data is not a JWT.
Sourcepub fn check(&self) -> Result<(), CredentialError>
pub fn check(&self) -> Result<(), CredentialError>
Checks that type includes the enveloped type and id is a data: URL.
§Errors
CredentialError::MissingType or CredentialError::NotDataUrl.
Source§impl EnvelopedVc
impl EnvelopedVc
Sourcepub const SD_JWT_MEDIA_TYPE: &'static str = crate::sd_jwt_vc::SdJwtCredentialV2::MEDIA_TYPE
Available on crate feature sd-jwt only.
pub const SD_JWT_MEDIA_TYPE: &'static str = crate::sd_jwt_vc::SdJwtCredentialV2::MEDIA_TYPE
sd-jwt only.The media type of a credential secured with SD-JWT (VC-JOSE-COSE §3.2.1),
application/vc+sd-jwt.
Sourcepub fn from_sd_jwt(sd_jwt: &SdJwt) -> Self
Available on crate feature sd-jwt only.
pub fn from_sd_jwt(sd_jwt: &SdJwt) -> Self
sd-jwt only.An envelope for sd_jwt, in its compact serialization.
Sourcepub fn to_sd_jwt(&self) -> Result<SdJwt, CredentialError>
Available on crate feature sd-jwt only.
pub fn to_sd_jwt(&self) -> Result<SdJwt, CredentialError>
sd-jwt only.The SD-JWT the envelope holds, parsed but not processed; see
SdJwtCredentialV2::from_sd_jwt
for the credential it secures.
§Errors
CredentialError::UnsupportedMediaType when the media type is not
application/vc+sd-jwt, and CredentialError::InvalidClaim when the data is not
an SD-JWT.
Trait Implementations§
Source§impl Clone for EnvelopedVc
impl Clone for EnvelopedVc
Source§impl Debug for EnvelopedVc
impl Debug for EnvelopedVc
Source§impl<'de> Deserialize<'de> for EnvelopedVc
impl<'de> Deserialize<'de> for EnvelopedVc
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 object and checks its type and that id is a data: URL.
impl Eq for EnvelopedVc
Source§impl PartialEq for EnvelopedVc
impl PartialEq for EnvelopedVc
Source§impl Serialize for EnvelopedVc
impl Serialize for EnvelopedVc
impl StructuralPartialEq for EnvelopedVc
Auto Trait Implementations§
impl Freeze for EnvelopedVc
impl RefUnwindSafe for EnvelopedVc
impl Send for EnvelopedVc
impl Sync for EnvelopedVc
impl Unpin for EnvelopedVc
impl UnsafeUnpin for EnvelopedVc
impl UnwindSafe for EnvelopedVc
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.