JavaScript is disabled, refresh for a better experience. ambee/giterated

ambee/giterated

Git repository hosting, collaboration, and discovery for the Fediverse.

Finish unified stack refactor.

Adds support for operation state, which will be used to pass authentication information around. Added generic backend that uses a channel to communicate with a typed backend.

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨d15581c

⁨giterated-models/src/operation.rs⁩ - ⁨916⁩ bytes
Raw
1 use std::{any::type_name, fmt::Debug};
2
3 use serde::{de::DeserializeOwned, Deserialize, Serialize};
4 use serde_json::Value;
5
6 use crate::object::GiteratedObject;
7
8 pub trait GiteratedOperation<O: GiteratedObject>: Send + Serialize + DeserializeOwned {
9 type Success: Serialize + DeserializeOwned + Send;
10 type Failure: Serialize + DeserializeOwned + Send;
11
12 fn operation_name() -> &'static str {
13 type_name::<Self>()
14 }
15 }
16
17 #[derive(Clone, Debug, Serialize, Deserialize)]
18 #[serde(transparent)]
19 #[repr(transparent)]
20 pub struct AnyOperation(pub Value);
21
22 impl<O: GiteratedObject> GiteratedOperation<O> for AnyOperation {
23 type Success = Value;
24
25 type Failure = Value;
26 }
27
28 /// The internal state of an operation, used to provide authentication information
29 /// and the ability to make giterated calls within handlers.
30 #[derive(Clone)]
31 pub struct GiteratedOperationState<S: Clone + Send + Sync>(pub S);
32