1 |
use serde::{Deserialize, Serialize};
|
2 |
|
3 |
use crate::{
|
4 |
error::{OperationError, 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>, OperationError<UserError>> {
|
26 |
self.request::<UserRepositoriesRequest>(UserRepositoriesRequest {
|
27 |
instance: instance.clone(),
|
28 |
user: self.inner.clone(),
|
29 |
})
|
30 |
.await
|
31 |
}
|
32 |
}
|
33 |
|