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

ambee/giterated

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

Unified stack `GetValue` implementation

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨325f5af

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