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

ambee/giterated

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

Begin new protocol refactor

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨26651b1

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