pub mod email; pub mod repo; use tonic::transport::{Channel, Endpoint}; #[derive(Clone)] pub struct RepoClient { pub repository: repo::repository_service_client::RepositoryServiceClient, pub commit: repo::commit_service_client::CommitServiceClient, pub branch: repo::branch_service_client::BranchServiceClient, pub tag: repo::tag_service_client::TagServiceClient, pub tree: repo::tree_service_client::TreeServiceClient, pub diff: repo::diff_service_client::DiffServiceClient, pub merge: repo::merge_service_client::MergeServiceClient, pub blame: repo::blame_service_client::BlameServiceClient, pub archive: repo::archive_service_client::ArchiveServiceClient, pub pack: repo::pack_service_client::PackServiceClient, } impl RepoClient { pub async fn connect(addr: impl Into) -> Result> { let channel = Endpoint::from_shared(addr.into())?.connect().await?; Ok(Self::new(channel)) } pub fn lazy_connect(addr: impl Into) -> Result> { let channel = Endpoint::from_shared(addr.into())?.connect_lazy(); Ok(Self::new(channel)) } pub fn new(channel: Channel) -> Self { Self { repository: repo::repository_service_client::RepositoryServiceClient::new( channel.clone(), ), commit: repo::commit_service_client::CommitServiceClient::new(channel.clone()), branch: repo::branch_service_client::BranchServiceClient::new(channel.clone()), tag: repo::tag_service_client::TagServiceClient::new(channel.clone()), tree: repo::tree_service_client::TreeServiceClient::new(channel.clone()), diff: repo::diff_service_client::DiffServiceClient::new(channel.clone()), merge: repo::merge_service_client::MergeServiceClient::new(channel.clone()), blame: repo::blame_service_client::BlameServiceClient::new(channel.clone()), archive: repo::archive_service_client::ArchiveServiceClient::new(channel.clone()), pack: repo::pack_service_client::PackServiceClient::new(channel), } } } #[derive(Clone)] pub struct EmailClient { inner: email::email_service_client::EmailServiceClient, } impl EmailClient { pub async fn connect(addr: impl Into) -> Result> { let channel = Endpoint::from_shared(addr.into())?.connect().await?; Ok(Self::new(channel)) } pub fn lazy_connect(addr: impl Into) -> Result> { let channel = Endpoint::from_shared(addr.into())?.connect_lazy(); Ok(Self::new(channel)) } pub fn new(channel: Channel) -> Self { Self { inner: email::email_service_client::EmailServiceClient::new(channel), } } } impl std::ops::Deref for EmailClient { type Target = email::email_service_client::EmailServiceClient; fn deref(&self) -> &Self::Target { &self.inner } } impl std::ops::DerefMut for EmailClient { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.inner } }