Struct ye::Ye [−][src]
A Ye
instance is your single point of contact for interacting with DIDs and VCs.
Fields
plugins: Vec<Box<dyn YePlugin>>
registered plugins
Implementations
impl Ye
[src]
pub fn new() -> Self
[src]
Creates new Ye instance, vectors are initialized as empty.
pub async fn did_create(
&mut self,
did_method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
[src]
&mut self,
did_method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
Creates a new DID. May also persist a DID document for it, depending on plugin implementation.
Arguments
did_method
- did method to cater to, usually also used by plugins to decide if a plugins will process the requestoptions
- JSON string with additional information supporting the request (e.g. authentication data)payload
- JSON string with information for the request (e.g. actual data to write)
Example
use ye::Ye; async fn example() -> Result<(), Box<dyn std::error::Error>> { let mut ye = Ye::new(); // // register example plugin e.g. with // ye.register_plugin(example_plugin); let results = ye.did_create("did:example", "", "").await?; if !results.is_empty() { println!("created new did: {}", results[0].as_ref().ok_or("result not found")?); } Ok(()) }
pub async fn did_resolve(
&mut self,
did: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
[src]
&mut self,
did: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
Fetch data about a DID. This usually returns a DID document.
Arguments
did
- did to fetch data for
Example
use ye::Ye; async fn example() -> Result<(), Box<dyn std::error::Error>> { let mut ye = Ye::new(); // // register example plugin e.g. with // ye.register_plugin(example_plugin); let results = ye.did_resolve("did:example:123").await?; if !results.is_empty() { println!("got did: {}", results[0].as_ref().ok_or("result not found")?); } Ok(()) }
pub async fn did_update(
&mut self,
did: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
[src]
&mut self,
did: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
Updates data related to a DID. May also persist a DID document for it, depending on plugin implementation.
Arguments
did
- DID to update data foroptions
- JSON string with additional information supporting the request (e.g. authentication data)payload
- JSON string with information for the request (e.g. actual data to write)
Example
use ye::Ye; async fn example() -> Result<(), Box<dyn std::error::Error>> { let mut ye = Ye::new(); // // register example plugin e.g. with // ye.register_plugin(example_plugin); let results = ye.did_update("did:example", "", "").await?; if !results.is_empty() { println!("did successfully updated: {}", results[0].as_ref().ok_or("result not found")?); } Ok(()) }
pub fn register_plugin(&mut self, plugin: Box<dyn YePlugin>)
[src]
Registers a new plugin. See YePlugin
for details about how they work.
Arguments
plugin
- plugin to register
Example
use ye::Ye; // use some_crate::ExamplePlugin; async fn example() -> Result<(), Box<dyn std::error::Error>> { let mut ye = Ye::new(); let mut example_plugin = ExamplePlugin::new(); ye.register_plugin(Box::from(example_plugin)); let results = ye.did_create("did:example", "", "").await?; if !results.is_empty() { println!("did successfully updated: {}", results[0].as_ref().ok_or("result not found")?); } Ok(()) }
pub async fn run_custom_function(
&mut self,
method: &str,
function: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
[src]
&mut self,
method: &str,
function: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
Runs a custom function, this allows to use Ye
s API for custom calls, that do not belong
to Ye
s core functionality but may be required for a projects use cases.
Arguments
method
- method to call a function for (e.g. “did:example”)function
- function to call (e.g. “test connection”)options
- JSON string with additional information supporting the request (e.g. authentication data)payload
- JSON string with information for the request (e.g. actual data to write)
Example
use ye::Ye; async fn example() -> Result<(), Box<dyn std::error::Error>> { let mut ye = Ye::new(); // // register example plugin e.g. with // ye.register_plugin(example_plugin); let results = ye.run_custom_function("did:example", "test connection", "", "").await?; if !results.is_empty() { println!("connection status is: {}", results[0].as_ref().ok_or("result not found")?); } Ok(()) }
pub async fn vc_zkp_create_credential_definition(
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
[src]
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
Creates a new zero-knowledge proof credential definition. A credential definition holds cryptographic key material and is needed by an issuer to issue a credential, thus needs to be created before issuance. A credential definition is always bound to one credential schema.
Arguments
method
- method to create a credential definition for (e.g. “did:example”)options
- JSON string with additional information supporting the request (e.g. authentication data)payload
- JSON string with information for the request (e.g. actual data to write)
Example
use ye::Ye; async fn example() -> Result<(), Box<dyn std::error::Error>> { let mut ye = Ye::new(); // // register example plugin e.g. with // ye.register_plugin(example_plugin); let results = ye.vc_zkp_create_credential_definition("did:example", "", "").await?; if !results.is_empty() { println!("created a credential definition: {}", results[0].as_ref().ok_or("result not found")?); } Ok(()) }
pub async fn vc_zkp_create_credential_offer(
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
[src]
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
Creates a new zero-knowledge proof credential offer. This message is the response to a credential proposal.
Arguments
method
- method to create a credential offer for (e.g. “did:example”)options
- JSON string with additional information supporting the request (e.g. authentication data)payload
- JSON string with information for the request (e.g. actual data to write)
Example
use ye::Ye; async fn example() -> Result<(), Box<dyn std::error::Error>> { let mut ye = Ye::new(); // // register example plugin e.g. with // ye.register_plugin(example_plugin); let results = ye.vc_zkp_create_credential_offer("did:example", "", "").await?; if !results.is_empty() { println!("created a credential offer: {}", results[0].as_ref().ok_or("result not found")?); } Ok(()) }
pub async fn vc_zkp_create_credential_proposal(
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
[src]
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
Creates a new zero-knowledge proof credential proposal. This message is the first in the credential issuance flow.
Arguments
method
- method to create a credential proposal for (e.g. “did:example”)options
- JSON string with additional information supporting the request (e.g. authentication data)payload
- JSON string with information for the request (e.g. actual data to write)
Example
use ye::Ye; async fn example() -> Result<(), Box<dyn std::error::Error>> { let mut ye = Ye::new(); // // register example plugin e.g. with // ye.register_plugin(example_plugin); let results = ye.vc_zkp_create_credential_proposal("did:example", "", "").await?; if !results.is_empty() { println!("created a credential proposal: {}", results[0].as_ref().ok_or("result not found")?); } Ok(()) }
pub async fn vc_zkp_create_credential_schema(
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
[src]
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
Creates a new zero-knowledge proof credential schema. The schema specifies properties a credential includes, both optional and mandatory.
Arguments
method
- method to create a credential schema for (e.g. “did:example”)options
- JSON string with additional information supporting the request (e.g. authentication data)payload
- JSON string with information for the request (e.g. actual data to write)
Example
use ye::Ye; async fn example() -> Result<(), Box<dyn std::error::Error>> { let mut ye = Ye::new(); // // register example plugin e.g. with // ye.register_plugin(example_plugin); let results = ye.vc_zkp_create_credential_schema("did:example", "", "").await?; if !results.is_empty() { println!("created a credential schema: {}", results[0].as_ref().ok_or("result not found")?); } Ok(()) }
pub async fn vc_zkp_create_revocation_registry_definition(
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
[src]
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
Creates a new revocation registry definition. The definition consists of a public and a private part. The public part holds the cryptographic material needed to create non-revocation proofs. The private part needs to reside with the registry owner and is used to revoke credentials.
Arguments
method
- method to create a revocation registry definition for (e.g. “did:example”)options
- JSON string with additional information supporting the request (e.g. authentication data)payload
- JSON string with information for the request (e.g. actual data to write)
Example
use ye::Ye; async fn example() -> Result<(), Box<dyn std::error::Error>> { let mut ye = Ye::new(); // // register example plugin e.g. with // ye.register_plugin(example_plugin); let results = ye.vc_zkp_create_revocation_registry_definition("did:example", "", "").await?; if !results.is_empty() { println!("created a revocation registry definition: {}", results[0].as_ref().ok_or("result not found")?); } Ok(()) }
pub async fn vc_zkp_update_revocation_registry(
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
[src]
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
Updates a revocation registry for a zero-knowledge proof. This step is necessary after revocation one or more credentials.
Arguments
method
- method to update a revocation registry for (e.g. “did:example”)options
- JSON string with additional information supporting the request (e.g. authentication data)payload
- JSON string with information for the request (e.g. actual data to write)
Example
use ye::Ye; async fn example() -> Result<(), Box<dyn std::error::Error>> { let mut ye = Ye::new(); // // register example plugin e.g. with // ye.register_plugin(example_plugin); let results = ye.vc_zkp_update_revocation_registry("did:example", "", "").await?; if !results.is_empty() { println!("updated revocation registry: {}", results[0].as_ref().ok_or("result not found")?); } Ok(()) }
pub async fn vc_zkp_issue_credential(
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
[src]
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
Issues a new credential. This requires an issued schema, credential definition, an active revocation registry and a credential request message.
Arguments
method
- method to issue a credential for (e.g. “did:example”)options
- JSON string with additional information supporting the request (e.g. authentication data)payload
- JSON string with information for the request (e.g. actual data to write)
Example
use ye::Ye; async fn example() -> Result<(), Box<dyn std::error::Error>> { let mut ye = Ye::new(); // // register example plugin e.g. with // ye.register_plugin(example_plugin); let results = ye.vc_zkp_issue_credential("did:example", "", "").await?; if !results.is_empty() { println!("issued credential: {}", results[0].as_ref().ok_or("result not found")?); } Ok(()) }
pub async fn vc_zkp_present_proof(
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
[src]
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
Presents a proof for a zero-knowledge proof credential. A proof presentation is the response to a proof request.
Arguments
method
- method to presents a proof for (e.g. “did:example”)options
- JSON string with additional information supporting the request (e.g. authentication data)payload
- JSON string with information for the request (e.g. actual data to write)
Example
use ye::Ye; async fn example() -> Result<(), Box<dyn std::error::Error>> { let mut ye = Ye::new(); // // register example plugin e.g. with // ye.register_plugin(example_plugin); let results = ye.vc_zkp_present_proof("did:example", "", "").await?; if !results.is_empty() { println!("created a proof presentation: {}", results[0].as_ref().ok_or("result not found")?); } Ok(()) }
pub async fn vc_zkp_request_credential(
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
[src]
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
Requests a credential. This message is the response to a credential offering.
Arguments
method
- method to request a credential for (e.g. “did:example”)options
- JSON string with additional information supporting the request (e.g. authentication data)payload
- JSON string with information for the request (e.g. actual data to write)
Example
use ye::Ye; async fn example() -> Result<(), Box<dyn std::error::Error>> { let mut ye = Ye::new(); // // register example plugin e.g. with // ye.register_plugin(example_plugin); let results = ye.vc_zkp_request_credential("did:example", "", "").await?; if !results.is_empty() { println!("created credential request: {}", results[0].as_ref().ok_or("result not found")?); } Ok(()) }
pub async fn vc_zkp_request_proof(
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
[src]
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
Requests a zero-knowledge proof for one or more credentials issued under one or more specific schemas.
Arguments
method
- method to request a proof for (e.g. “did:example”)options
- JSON string with additional information supporting the request (e.g. authentication data)payload
- JSON string with information for the request (e.g. actual data to write)
Example
use ye::Ye; async fn example() -> Result<(), Box<dyn std::error::Error>> { let mut ye = Ye::new(); // // register example plugin e.g. with // ye.register_plugin(example_plugin); let results = ye.vc_zkp_request_proof("did:example", "", "").await?; if !results.is_empty() { println!("created proof request: {}", results[0].as_ref().ok_or("result not found")?); } Ok(()) }
pub async fn vc_zkp_revoke_credential(
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
[src]
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
Revokes a credential. After revocation the published revocation registry needs to be updated with information returned by this function.
Arguments
method
- method to revoke a credential for (e.g. “did:example”)options
- JSON string with additional information supporting the request (e.g. authentication data)payload
- JSON string with information for the request (e.g. actual data to write)
Example
use ye::Ye; async fn example() -> Result<(), Box<dyn std::error::Error>> { let mut ye = Ye::new(); // // register example plugin e.g. with // ye.register_plugin(example_plugin); let results = ye.vc_zkp_revoke_credential("did:example", "", "").await?; if !results.is_empty() { println!("revoked credential: {}", results[0].as_ref().ok_or("result not found")?); } Ok(()) }
pub async fn vc_zkp_verify_proof(
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
[src]
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
Verifies one or multiple proofs sent in a proof presentation.
Arguments
method
- method to verify a proof for (e.g. “did:example”)options
- JSON string with additional information supporting the request (e.g. authentication data)payload
- JSON string with information for the request (e.g. actual data to write)
Example
use ye::Ye; async fn example() -> Result<(), Box<dyn std::error::Error>> { let mut ye = Ye::new(); // // register example plugin e.g. with // ye.register_plugin(example_plugin); let results = ye.vc_zkp_verify_proof("did:example", "", "").await?; if !results.is_empty() { println!("verified proof: {}", results[0].as_ref().ok_or("result not found")?); } Ok(()) }
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Ye
impl !Send for Ye
impl !Sync for Ye
impl Unpin for Ye
impl !UnwindSafe for Ye
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,