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

ambee/giterated

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

More progress :)

Amber - ⁨1⁩ year ago

parent: tbd commit: ⁨92c3f32

⁨giterated-models/src/user/operations.rs⁩ - ⁨1066⁩ bytes
Raw
1 use serde::{Deserialize, Serialize};
2
3 use crate::{
4 error::{OperationError, UserError},
5 instance::Instance,
6 object::Object,
7 object_backend::ObjectBackend,
8 operation::{GiteratedOperation, OperationState},
9 repository::RepositorySummary,
10 };
11
12 use super::User;
13
14 #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
15 pub struct UserRepositoriesRequest {
16 pub instance: Instance,
17 pub user: User,
18 }
19
20 impl GiteratedOperation<User> for UserRepositoriesRequest {
21 type Success = Vec<RepositorySummary>;
22 type Failure = UserError;
23 }
24
25 impl<B: ObjectBackend + std::fmt::Debug> Object<User, B> {
26 pub async fn repositories(
27 &mut self,
28 instance: &Instance,
29 operation_state: &OperationState,
30 ) -> Result<Vec<RepositorySummary>, OperationError<UserError>> {
31 self.request::<UserRepositoriesRequest>(
32 UserRepositoriesRequest {
33 instance: instance.clone(),
34 user: self.inner.clone(),
35 },
36 operation_state,
37 )
38 .await
39 }
40 }
41