Git repository hosting, collaboration, and discovery for the Fediverse.
Fixes!
parent: tbd commit: 46cd262
Showing 3 changed files with 37 insertions and 8 deletions
Cargo.toml
@@ -24,4 +24,5 @@ anyhow = "*" | ||
24 | 24 | deadpool = "*" |
25 | 25 | async-trait = "*" |
26 | 26 | thiserror = "*" |
27 | semver = "*" | |
27 | \ No newline at end of file | |
27 | semver = "*" | |
28 | color-eyre = "0.6.2" | |
28 | \ No newline at end of file |
src/daemon_backend.rs
@@ -19,12 +19,13 @@ impl ObjectBackend for DaemonConnectionPool { | ||
19 | 19 | async fn object_operation<O: GiteratedObject + Debug, D: GiteratedOperation<O> + Debug>( |
20 | 20 | &self, |
21 | 21 | object: O, |
22 | operation: D, | |
22 | operation: &str, | |
23 | payload: D, | |
23 | 24 | ) -> Result<D::Success, OperationError<D::Failure>> { |
24 | 25 | let message = GiteratedMessage { |
25 | 26 | object, |
26 | operation: D::operation_name().to_string(), | |
27 | payload: operation, | |
27 | operation: operation.to_string(), | |
28 | payload, | |
28 | 29 | }; |
29 | 30 | |
30 | 31 | let mut connection = self |
@@ -93,8 +94,24 @@ async fn send_expect< | ||
93 | 94 | } |
94 | 95 | }; |
95 | 96 | |
96 | let _as_target = serde_json::from_slice::<R>(&payload) | |
97 | let raw_result = bincode::deserialize::<Result<Vec<u8>, OperationError<Vec<u8>>>>(&payload) | |
97 | 98 | .map_err(|e| OperationError::Internal(e.to_string()))?; |
99 | ||
100 | // Map ok | |
101 | let raw_result = match raw_result { | |
102 | Ok(raw) => Ok(serde_json::from_slice(&raw) | |
103 | .map_err(|e| OperationError::Internal(e.to_string()))?), | |
104 | Err(err) => Err(match err { | |
105 | OperationError::Operation(err) => OperationError::Operation( | |
106 | serde_json::from_slice(&err) | |
107 | .map_err(|e| OperationError::Internal(e.to_string()))?, | |
108 | ), | |
109 | OperationError::Internal(err) => OperationError::Internal(err), | |
110 | OperationError::Unhandled => OperationError::Unhandled, | |
111 | }), | |
112 | }; | |
113 | ||
114 | return raw_result; | |
98 | 115 | } |
99 | 116 | |
100 | 117 | panic!() |
src/main.rs
@@ -7,9 +7,14 @@ use giterated_models::{ | ||
7 | 7 | user::{DisplayName, User}, |
8 | 8 | }; |
9 | 9 | |
10 | use color_eyre::eyre::Result; | |
11 | use tracing::info; | |
12 | ||
10 | 13 | #[tokio::main] |
11 | async fn main() -> Result<(), anyhow::Error> { | |
14 | async fn main() -> Result<()> { | |
12 | 15 | tracing_subscriber::fmt::init(); |
16 | color_eyre::install()?; | |
17 | ||
13 | 18 | let pool = DaemonConnectionPool::connect_other( |
14 | 19 | Instance::from_str("giterated.dev")?, |
15 | 20 | ("127.0.0.1:1111").parse().unwrap(), |
@@ -18,11 +23,17 @@ async fn main() -> Result<(), anyhow::Error> { | ||
18 | 23 | |
19 | 24 | let mut user = pool.get_object::<User>("ambee:giterated.dev").await?; |
20 | 25 | |
21 | let _display_name = user.get::<DisplayName>().await?; | |
26 | info!("Getting display name for {}!", user); | |
27 | ||
28 | let display_name = user.get::<DisplayName>().await?; | |
22 | 29 | |
23 | let _repositories = user | |
30 | info!("{}'s display name is {}", user, display_name); | |
31 | ||
32 | let repositories = user | |
24 | 33 | .repositories(&Instance::from_str("giterated.dev").unwrap()) |
25 | 34 | .await?; |
26 | 35 | |
36 | info!("Repository: {:#?}", repositories); | |
37 | ||
27 | 38 | Ok(()) |
28 | 39 | } |