generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
005bd3c
commit ef1a319
Showing
35 changed files
with
656 additions
and
469 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
bindings/web5_uniffi_wrapper/src/dids/resolution/resolution_result.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
use errors::Result; | ||
use tokio::runtime::Runtime; | ||
use web5::errors::Web5Error; | ||
|
||
pub mod credentials; | ||
pub mod crypto; | ||
pub mod dids; | ||
|
||
pub mod errors; | ||
|
||
pub fn get_rt() -> Result<Runtime> { | ||
let rt = Runtime::new() | ||
.map_err(|e| Web5Error::Unknown(format!("unable to instantiate tokio runtime {}", e)))?; | ||
Ok(rt) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,54 @@ | ||
use crate::Result; | ||
use std::collections::HashMap; | ||
use crate::{Error, Result}; | ||
use async_trait::async_trait; | ||
use serde::{Deserialize, Serialize}; | ||
use std::{collections::HashMap, fmt, str::FromStr}; | ||
|
||
#[async_trait] | ||
pub trait Client: Send + Sync { | ||
fn fetch(&self, url: &str, options: Option<FetchOptions>) -> Result<Response>; | ||
async fn fetch(&self, url: &str, options: Option<FetchOptions>) -> Result<Response>; | ||
} | ||
|
||
#[derive(Default)] | ||
#[derive(Default, Serialize, Deserialize)] | ||
pub struct FetchOptions { | ||
pub method: Option<Method>, | ||
pub headers: Option<HashMap<String, String>>, | ||
pub body: Option<Vec<u8>>, | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct Response { | ||
pub status_code: u16, | ||
pub headers: HashMap<String, String>, | ||
pub body: Vec<u8>, | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub enum Method { | ||
Get, | ||
Post, | ||
Put, | ||
} | ||
|
||
impl ToString for Method { | ||
fn to_string(&self) -> String { | ||
match self { | ||
Method::Get => "GET".to_string(), | ||
Method::Post => "POST".to_string(), | ||
Method::Put => "PUT".to_string(), | ||
impl fmt::Display for Method { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
let method_str = match self { | ||
Method::Get => "GET", | ||
Method::Post => "POST", | ||
Method::Put => "PUT", | ||
}; | ||
write!(f, "{}", method_str) | ||
} | ||
} | ||
|
||
impl FromStr for Method { | ||
type Err = Error; | ||
|
||
fn from_str(s: &str) -> Result<Self> { | ||
match s.to_ascii_uppercase().as_ref() { | ||
"GET" => Ok(Method::Get), | ||
"POST" => Ok(Method::Post), | ||
"PUT" => Ok(Method::Put), | ||
_ => Err(Error::Parameter(format!("unknown method {}", s))), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.