Rewrite rust (#38)
Co-authored-by: kjuulh <contact@kjuulh.io> Reviewed-on: https://git.front.kjuulh.io/kjuulh/octopush/pulls/38
This commit is contained in:
29
crates/gitea_client/src/client.rs
Normal file
29
crates/gitea_client/src/client.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use gitea_raw_client::apis::configuration::Configuration;
|
||||
|
||||
use crate::apis::{defaults::repository::DefaultRepository, repository::DynRepository};
|
||||
|
||||
pub struct GiteaClient {
|
||||
repository: DynRepository,
|
||||
}
|
||||
|
||||
impl GiteaClient {
|
||||
pub fn new(config: Configuration) -> Self {
|
||||
let conf = Arc::new(config);
|
||||
|
||||
Self {
|
||||
repository: Arc::new(DefaultRepository::new(conf.clone())),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn repository(&self) -> DynRepository {
|
||||
self.repository.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Configuration> for GiteaClient {
|
||||
fn from(conf: Configuration) -> Self {
|
||||
Self::new(conf)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user