server/lib/src/generated/holger.account.v1.rs
// This file is @generated by prost-build.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GrantRequest {
#[prost(string, tag = "1")]
pub repository: ::prost::alloc::string::String,
/// The person: their name on this server, or their subject (`passkey:…`).
#[prost(string, tag = "2")]
pub person: ::prost::alloc::string::String,
/// `read`, `write` (read and write) or `none` (revoke).
#[prost(string, tag = "3")]
pub access: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GrantReply {
#[prost(string, tag = "1")]
pub repository: ::prost::alloc::string::String,
/// Every grant the repository holds now.
#[prost(message, repeated, tag = "2")]
pub grants: ::prost::alloc::vec::Vec<RepositoryGrant>,
/// One sentence for the console.
#[prost(string, tag = "3")]
pub words: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct RepositoryGrant {
/// The person's name here (their subject when no name is known).
#[prost(string, tag = "1")]
pub person: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub subject: ::prost::alloc::string::String,
/// `read` or `write`.
#[prost(string, tag = "3")]
pub access: ::prost::alloc::string::String,
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct MyRepositoriesRequest {}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MyRepositoriesReply {
#[prost(message, repeated, tag = "1")]
pub repositories: ::prost::alloc::vec::Vec<MyRepository>,
/// The formats CreateRepository makes here for this caller ("cargo", "pip",
/// "npm", "maven", "raw", "oci"). Empty: this caller makes none.
#[prost(string, repeated, tag = "2")]
pub formats: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// One sentence for the console to show as it is: who may make one, or why
/// nothing is listed.
#[prost(string, tag = "3")]
pub words: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MyRepository {
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// The client's word for its format: "cargo", "pip", "npm", "maven", "raw",
/// "oci", or the server's own type name for any other.
#[prost(string, tag = "2")]
pub format: ::prost::alloc::string::String,
/// Its reads need a credential of this server.
#[prost(bool, tag = "3")]
pub private: bool,
/// The principal it was made for; empty for the estate's own repositories and
/// for a sale whose buyer has not registered yet.
#[prost(string, tag = "4")]
pub owner: ::prost::alloc::string::String,
/// A door serves it now. False: it is made and is served from the next start
/// (`words` says why).
#[prost(bool, tag = "5")]
pub served: bool,
/// The client setup for this repository, written by this server.
#[prost(message, repeated, tag = "6")]
pub clients: ::prost::alloc::vec::Vec<ClientSetup>,
/// One sentence for the console to show as it is.
#[prost(string, tag = "7")]
pub words: ::prost::alloc::string::String,
/// ── Its plan, as this server holds it (the ONE shop's signed fact) ──
/// The plan's name; empty when nothing is bought for it (it is free).
#[prost(string, tag = "8")]
pub plan: ::prost::alloc::string::String,
/// This server's word for where the plan stands: "free", "paid", "grace",
/// "suspended", "retention", or "lapsed" (paid until a date that has passed,
/// and no renewal has reached this server: uploads are refused until it is
/// paid again).
#[prost(string, tag = "9")]
pub plan_state: ::prost::alloc::string::String,
/// Paid until, Unix milliseconds; 0 when the fact names no date.
#[prost(int64, tag = "10")]
pub paid_until_unix_ms: i64,
/// One sentence for the console to show as it is, about the plan.
#[prost(string, tag = "11")]
pub plan_words: ::prost::alloc::string::String,
/// The people its owner granted (lane P1): shown to its owner and to an admin only.
#[prost(message, repeated, tag = "12")]
pub grants: ::prost::alloc::vec::Vec<RepositoryGrant>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ClientSetup {
/// "cargo", "pip", "npm", "maven", "curl", "docker".
#[prost(string, tag = "1")]
pub client: ::prost::alloc::string::String,
/// Where the snippet goes ("~/.cargo/config.toml"), or "shell".
#[prost(string, tag = "2")]
pub file: ::prost::alloc::string::String,
/// The text, with YOUR-TOKEN where a token from My tokens goes.
#[prost(string, tag = "3")]
pub snippet: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct CreateRepositoryRequest {
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// One of `MyRepositoriesReply.formats`.
#[prost(string, tag = "2")]
pub format: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateRepositoryReply {
#[prost(message, optional, tag = "1")]
pub repository: ::core::option::Option<MyRepository>,
/// One sentence for the console to show as it is.
#[prost(string, tag = "2")]
pub words: ::prost::alloc::string::String,
}
/// Generated client implementations.
pub mod account_service_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct AccountServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl AccountServiceClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> AccountServiceClient<T>
where
T: tonic::client::GrpcService<tonic::body::Body>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> AccountServiceClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::Body>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::Body>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
AccountServiceClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// The repositories the caller has here: the ones made for them (they are the
/// owner), and for an ADMIN of this server every repository but the estate's
/// system ones. Anonymous: none, with the words to sign in. Never refused.
pub async fn my_repositories(
&mut self,
request: impl tonic::IntoRequest<super::MyRepositoriesRequest>,
) -> std::result::Result<
tonic::Response<super::MyRepositoriesReply>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/holger.account.v1.AccountService/MyRepositories",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new("holger.account.v1.AccountService", "MyRepositories"),
);
self.inner.unary(req, path, codec).await
}
/// ADMIN of this server. Make a PRIVATE repository the caller owns, in one of
/// the formats `MyRepositoriesReply.formats` names. Its reads need a
/// credential of this server from the first request. The name is taken once:
/// a name this server serves or has made is ALREADY_EXISTS; a name that is no
/// repository name is INVALID_ARGUMENT; a format this server makes none of is
/// FAILED_PRECONDITION. A twin, a growth or a read-only server refuses as
/// every admin change does. The repository rides the twin and comes back with
/// a recharge, as a sold one does.
pub async fn create_repository(
&mut self,
request: impl tonic::IntoRequest<super::CreateRepositoryRequest>,
) -> std::result::Result<
tonic::Response<super::CreateRepositoryReply>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/holger.account.v1.AccountService/CreateRepository",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"holger.account.v1.AccountService",
"CreateRepository",
),
);
self.inner.unary(req, path, codec).await
}
/// **The owner grants or revokes** (lane P1): a named person (their name here, or their
/// subject) may read, or read and write, one owner-only repository; `none` revokes. Its
/// OWNER only, or an admin of this server; every change is audited. The person keeps no
/// role elsewhere from it.
pub async fn grant(
&mut self,
request: impl tonic::IntoRequest<super::GrantRequest>,
) -> std::result::Result<tonic::Response<super::GrantReply>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/holger.account.v1.AccountService/Grant",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("holger.account.v1.AccountService", "Grant"));
self.inner.unary(req, path, codec).await
}
}
}
/// Generated server implementations.
pub mod account_service_server {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
/// Generated trait containing gRPC methods that should be implemented for use with AccountServiceServer.
#[async_trait]
pub trait AccountService: std::marker::Send + std::marker::Sync + 'static {
/// The repositories the caller has here: the ones made for them (they are the
/// owner), and for an ADMIN of this server every repository but the estate's
/// system ones. Anonymous: none, with the words to sign in. Never refused.
async fn my_repositories(
&self,
request: tonic::Request<super::MyRepositoriesRequest>,
) -> std::result::Result<
tonic::Response<super::MyRepositoriesReply>,
tonic::Status,
>;
/// ADMIN of this server. Make a PRIVATE repository the caller owns, in one of
/// the formats `MyRepositoriesReply.formats` names. Its reads need a
/// credential of this server from the first request. The name is taken once:
/// a name this server serves or has made is ALREADY_EXISTS; a name that is no
/// repository name is INVALID_ARGUMENT; a format this server makes none of is
/// FAILED_PRECONDITION. A twin, a growth or a read-only server refuses as
/// every admin change does. The repository rides the twin and comes back with
/// a recharge, as a sold one does.
async fn create_repository(
&self,
request: tonic::Request<super::CreateRepositoryRequest>,
) -> std::result::Result<
tonic::Response<super::CreateRepositoryReply>,
tonic::Status,
>;
/// **The owner grants or revokes** (lane P1): a named person (their name here, or their
/// subject) may read, or read and write, one owner-only repository; `none` revokes. Its
/// OWNER only, or an admin of this server; every change is audited. The person keeps no
/// role elsewhere from it.
async fn grant(
&self,
request: tonic::Request<super::GrantRequest>,
) -> std::result::Result<tonic::Response<super::GrantReply>, tonic::Status>;
}
#[derive(Debug)]
pub struct AccountServiceServer<T> {
inner: Arc<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
max_decoding_message_size: Option<usize>,
max_encoding_message_size: Option<usize>,
}
impl<T> AccountServiceServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
max_decoding_message_size: None,
max_encoding_message_size: None,
}
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> InterceptedService<Self, F>
where
F: tonic::service::Interceptor,
{
InterceptedService::new(Self::new(inner), interceptor)
}
/// Enable decompressing requests with the given encoding.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.accept_compression_encodings.enable(encoding);
self
}
/// Compress responses with the given encoding, if the client supports it.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.send_compression_encodings.enable(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.max_decoding_message_size = Some(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.max_encoding_message_size = Some(limit);
self
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for AccountServiceServer<T>
where
T: AccountService,
B: Body + std::marker::Send + 'static,
B::Error: Into<StdError> + std::marker::Send + 'static,
{
type Response = http::Response<tonic::body::Body>;
type Error = std::convert::Infallible;
type Future = BoxFuture<Self::Response, Self::Error>;
fn poll_ready(
&mut self,
_cx: &mut Context<'_>,
) -> Poll<std::result::Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
match req.uri().path() {
"/holger.account.v1.AccountService/MyRepositories" => {
#[allow(non_camel_case_types)]
struct MyRepositoriesSvc<T: AccountService>(pub Arc<T>);
impl<
T: AccountService,
> tonic::server::UnaryService<super::MyRepositoriesRequest>
for MyRepositoriesSvc<T> {
type Response = super::MyRepositoriesReply;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::MyRepositoriesRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as AccountService>::my_repositories(&inner, request)
.await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = MyRepositoriesSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/holger.account.v1.AccountService/CreateRepository" => {
#[allow(non_camel_case_types)]
struct CreateRepositorySvc<T: AccountService>(pub Arc<T>);
impl<
T: AccountService,
> tonic::server::UnaryService<super::CreateRepositoryRequest>
for CreateRepositorySvc<T> {
type Response = super::CreateRepositoryReply;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::CreateRepositoryRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as AccountService>::create_repository(&inner, request)
.await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = CreateRepositorySvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/holger.account.v1.AccountService/Grant" => {
#[allow(non_camel_case_types)]
struct GrantSvc<T: AccountService>(pub Arc<T>);
impl<
T: AccountService,
> tonic::server::UnaryService<super::GrantRequest> for GrantSvc<T> {
type Response = super::GrantReply;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::GrantRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as AccountService>::grant(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = GrantSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => {
Box::pin(async move {
let mut response = http::Response::new(
tonic::body::Body::default(),
);
let headers = response.headers_mut();
headers
.insert(
tonic::Status::GRPC_STATUS,
(tonic::Code::Unimplemented as i32).into(),
);
headers
.insert(
http::header::CONTENT_TYPE,
tonic::metadata::GRPC_CONTENT_TYPE,
);
Ok(response)
})
}
}
}
}
impl<T> Clone for AccountServiceServer<T> {
fn clone(&self) -> Self {
let inner = self.inner.clone();
Self {
inner,
accept_compression_encodings: self.accept_compression_encodings,
send_compression_encodings: self.send_compression_encodings,
max_decoding_message_size: self.max_decoding_message_size,
max_encoding_message_size: self.max_encoding_message_size,
}
}
}
/// Generated gRPC service name
pub const SERVICE_NAME: &str = "holger.account.v1.AccountService";
impl<T> tonic::server::NamedService for AccountServiceServer<T> {
const NAME: &'static str = SERVICE_NAME;
}
}