pub trait PolicyService:
Send
+ Sync
+ 'static {
// Required methods
fn list_subaccount_policies<'a>(
&'a self,
ctx: RequestContext,
request: ServiceRequest<'_, ListSubaccountPoliciesRequest>,
) -> impl Future<Output = ServiceResult<impl Encodable<ListSubaccountPoliciesResponse> + Send + use<'a, Self>>> + Send;
fn get_subaccount_policy<'a>(
&'a self,
ctx: RequestContext,
request: ServiceRequest<'_, GetSubaccountPolicyRequest>,
) -> impl Future<Output = ServiceResult<impl Encodable<GetSubaccountPolicyResponse> + Send + use<'a, Self>>> + Send;
fn create_subaccount_policy<'a>(
&'a self,
ctx: RequestContext,
request: ServiceRequest<'_, CreateSubaccountPolicyRequest>,
) -> impl Future<Output = ServiceResult<impl Encodable<CreateSubaccountPolicyResponse> + Send + use<'a, Self>>> + Send;
fn update_subaccount_policy<'a>(
&'a self,
ctx: RequestContext,
request: ServiceRequest<'_, UpdateSubaccountPolicyRequest>,
) -> impl Future<Output = ServiceResult<impl Encodable<UpdateSubaccountPolicyResponse> + Send + use<'a, Self>>> + Send;
fn delete_subaccount_policy<'a>(
&'a self,
ctx: RequestContext,
request: ServiceRequest<'_, DeleteSubaccountPolicyRequest>,
) -> impl Future<Output = ServiceResult<impl Encodable<DeleteSubaccountPolicyResponse> + Send + use<'a, Self>>> + Send;
fn set_subaccount_policy<'a>(
&'a self,
ctx: RequestContext,
request: ServiceRequest<'_, SetSubaccountPolicyRequest>,
) -> impl Future<Output = ServiceResult<impl Encodable<SetSubaccountPolicyResponse> + Send + use<'a, Self>>> + Send;
fn list_api_policies<'a>(
&'a self,
ctx: RequestContext,
request: ServiceRequest<'_, ListApiPoliciesRequest>,
) -> impl Future<Output = ServiceResult<impl Encodable<ListApiPoliciesResponse> + Send + use<'a, Self>>> + Send;
fn get_api_policy<'a>(
&'a self,
ctx: RequestContext,
request: ServiceRequest<'_, GetApiPolicyRequest>,
) -> impl Future<Output = ServiceResult<impl Encodable<GetApiPolicyResponse> + Send + use<'a, Self>>> + Send;
fn create_api_policy<'a>(
&'a self,
ctx: RequestContext,
request: ServiceRequest<'_, CreateApiPolicyRequest>,
) -> impl Future<Output = ServiceResult<impl Encodable<CreateApiPolicyResponse> + Send + use<'a, Self>>> + Send;
fn update_api_policy<'a>(
&'a self,
ctx: RequestContext,
request: ServiceRequest<'_, UpdateApiPolicyRequest>,
) -> impl Future<Output = ServiceResult<impl Encodable<UpdateApiPolicyResponse> + Send + use<'a, Self>>> + Send;
fn delete_api_policy<'a>(
&'a self,
ctx: RequestContext,
request: ServiceRequest<'_, DeleteApiPolicyRequest>,
) -> impl Future<Output = ServiceResult<impl Encodable<DeleteApiPolicyResponse> + Send + use<'a, Self>>> + Send;
fn set_api_key_policy<'a>(
&'a self,
ctx: RequestContext,
request: ServiceRequest<'_, SetApiKeyPolicyRequest>,
) -> impl Future<Output = ServiceResult<impl Encodable<SetApiKeyPolicyResponse> + Send + use<'a, Self>>> + Send;
}Expand description
PolicyService manages sub-account and API key policy templates and bindings.
§Implementing handlers
Implement methods with plain async fn; the returned future satisfies
the Send bound automatically.
Unary and server-streaming requests arrive as
ServiceRequest<'_, Req>: a zero-copy
view of the request plus its body, valid for the duration of the call.
Fields are read directly (request.name is a &str into the decoded
buffer) and the borrow may be held across .await points. Anything
that must outlive the call — tokio::spawn, channels, server state,
or data captured by a returned response stream — takes owned data:
call request.to_owned_message() (or copy the specific fields)
first.
Client-streaming and bidi requests arrive as
InboundStream<Req> — a
ServiceStream of StreamMessages.
Each item owns its decoded buffer and is Send + 'static, so items
can be buffered or moved into spawned tasks; read fields zero-copy
through the generated accessor methods (item.name()) or .view(),
convert with .to_owned_message(), or yield an item back unchanged —
StreamMessage<M> implements Encodable<M>.
Request types resolved through extern_path (e.g. well-known types
from another crate) use the same wrappers; the crate that owns the
type must be generated with buffa ≥ 0.8.0 and views enabled so the
backing HasMessageView impl exists.
The impl Encodable<Out> return bound accepts the owned Out, the
generated OutView<'_> / OwnedOutView,
MaybeBorrowed, or
PreEncoded for handlers that encode a
non-'static view internally and pass the bytes across the handler
boundary. View bodies are not emitted for output types mapped via
extern_path (the impl would be an orphan); return owned for
WKT/extern outputs.
Server-streaming and bidi-streaming methods return
ServiceStream<impl Encodable<Out> + Send + use<Self>>. The
use<Self> precise-capturing clause excludes &self’s lifetime and
the request’s lifetime (unary methods use use<'a, Self> and may
borrow from &self), so stream items must be 'static and cannot
borrow from the request. To stream view-encoded data, encode each
item inside the stream body and yield
PreEncoded — see its # Streaming example doc.
Required Methods§
Sourcefn list_subaccount_policies<'a>(
&'a self,
ctx: RequestContext,
request: ServiceRequest<'_, ListSubaccountPoliciesRequest>,
) -> impl Future<Output = ServiceResult<impl Encodable<ListSubaccountPoliciesResponse> + Send + use<'a, Self>>> + Send
fn list_subaccount_policies<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, ListSubaccountPoliciesRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<ListSubaccountPoliciesResponse> + Send + use<'a, Self>>> + Send
List sub-account policy templates available to the caller.
'a lets the response body borrow from &self (e.g. server-resident state).
request is borrowed from the request body and is valid for the
duration of the call; message fields are read directly on it
(zero-copy). The response cannot borrow from request — use
.to_owned_message() (or copy the specific fields) for anything
returned, stored, or moved into tokio::spawn.
Sourcefn get_subaccount_policy<'a>(
&'a self,
ctx: RequestContext,
request: ServiceRequest<'_, GetSubaccountPolicyRequest>,
) -> impl Future<Output = ServiceResult<impl Encodable<GetSubaccountPolicyResponse> + Send + use<'a, Self>>> + Send
fn get_subaccount_policy<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, GetSubaccountPolicyRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<GetSubaccountPolicyResponse> + Send + use<'a, Self>>> + Send
Get a sub-account policy template by id.
'a lets the response body borrow from &self (e.g. server-resident state).
request is borrowed from the request body and is valid for the
duration of the call; message fields are read directly on it
(zero-copy). The response cannot borrow from request — use
.to_owned_message() (or copy the specific fields) for anything
returned, stored, or moved into tokio::spawn.
Sourcefn create_subaccount_policy<'a>(
&'a self,
ctx: RequestContext,
request: ServiceRequest<'_, CreateSubaccountPolicyRequest>,
) -> impl Future<Output = ServiceResult<impl Encodable<CreateSubaccountPolicyResponse> + Send + use<'a, Self>>> + Send
fn create_subaccount_policy<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, CreateSubaccountPolicyRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<CreateSubaccountPolicyResponse> + Send + use<'a, Self>>> + Send
Create a new sub-account policy template (optionally attach to a sub-account).
'a lets the response body borrow from &self (e.g. server-resident state).
request is borrowed from the request body and is valid for the
duration of the call; message fields are read directly on it
(zero-copy). The response cannot borrow from request — use
.to_owned_message() (or copy the specific fields) for anything
returned, stored, or moved into tokio::spawn.
Sourcefn update_subaccount_policy<'a>(
&'a self,
ctx: RequestContext,
request: ServiceRequest<'_, UpdateSubaccountPolicyRequest>,
) -> impl Future<Output = ServiceResult<impl Encodable<UpdateSubaccountPolicyResponse> + Send + use<'a, Self>>> + Send
fn update_subaccount_policy<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, UpdateSubaccountPolicyRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<UpdateSubaccountPolicyResponse> + Send + use<'a, Self>>> + Send
Change selected fields on an existing sub-account policy template.
'a lets the response body borrow from &self (e.g. server-resident state).
request is borrowed from the request body and is valid for the
duration of the call; message fields are read directly on it
(zero-copy). The response cannot borrow from request — use
.to_owned_message() (or copy the specific fields) for anything
returned, stored, or moved into tokio::spawn.
Sourcefn delete_subaccount_policy<'a>(
&'a self,
ctx: RequestContext,
request: ServiceRequest<'_, DeleteSubaccountPolicyRequest>,
) -> impl Future<Output = ServiceResult<impl Encodable<DeleteSubaccountPolicyResponse> + Send + use<'a, Self>>> + Send
fn delete_subaccount_policy<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, DeleteSubaccountPolicyRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<DeleteSubaccountPolicyResponse> + Send + use<'a, Self>>> + Send
Delete a sub-account policy template.
'a lets the response body borrow from &self (e.g. server-resident state).
request is borrowed from the request body and is valid for the
duration of the call; message fields are read directly on it
(zero-copy). The response cannot borrow from request — use
.to_owned_message() (or copy the specific fields) for anything
returned, stored, or moved into tokio::spawn.
Sourcefn set_subaccount_policy<'a>(
&'a self,
ctx: RequestContext,
request: ServiceRequest<'_, SetSubaccountPolicyRequest>,
) -> impl Future<Output = ServiceResult<impl Encodable<SetSubaccountPolicyResponse> + Send + use<'a, Self>>> + Send
fn set_subaccount_policy<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, SetSubaccountPolicyRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<SetSubaccountPolicyResponse> + Send + use<'a, Self>>> + Send
Attach or clear a sub-account policy for a sub-account.
'a lets the response body borrow from &self (e.g. server-resident state).
request is borrowed from the request body and is valid for the
duration of the call; message fields are read directly on it
(zero-copy). The response cannot borrow from request — use
.to_owned_message() (or copy the specific fields) for anything
returned, stored, or moved into tokio::spawn.
Sourcefn list_api_policies<'a>(
&'a self,
ctx: RequestContext,
request: ServiceRequest<'_, ListApiPoliciesRequest>,
) -> impl Future<Output = ServiceResult<impl Encodable<ListApiPoliciesResponse> + Send + use<'a, Self>>> + Send
fn list_api_policies<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, ListApiPoliciesRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<ListApiPoliciesResponse> + Send + use<'a, Self>>> + Send
List API key policy templates available to the caller.
'a lets the response body borrow from &self (e.g. server-resident state).
request is borrowed from the request body and is valid for the
duration of the call; message fields are read directly on it
(zero-copy). The response cannot borrow from request — use
.to_owned_message() (or copy the specific fields) for anything
returned, stored, or moved into tokio::spawn.
Sourcefn get_api_policy<'a>(
&'a self,
ctx: RequestContext,
request: ServiceRequest<'_, GetApiPolicyRequest>,
) -> impl Future<Output = ServiceResult<impl Encodable<GetApiPolicyResponse> + Send + use<'a, Self>>> + Send
fn get_api_policy<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, GetApiPolicyRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<GetApiPolicyResponse> + Send + use<'a, Self>>> + Send
Get an API key policy template by id.
'a lets the response body borrow from &self (e.g. server-resident state).
request is borrowed from the request body and is valid for the
duration of the call; message fields are read directly on it
(zero-copy). The response cannot borrow from request — use
.to_owned_message() (or copy the specific fields) for anything
returned, stored, or moved into tokio::spawn.
Sourcefn create_api_policy<'a>(
&'a self,
ctx: RequestContext,
request: ServiceRequest<'_, CreateApiPolicyRequest>,
) -> impl Future<Output = ServiceResult<impl Encodable<CreateApiPolicyResponse> + Send + use<'a, Self>>> + Send
fn create_api_policy<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, CreateApiPolicyRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<CreateApiPolicyResponse> + Send + use<'a, Self>>> + Send
Create a new API key policy template.
'a lets the response body borrow from &self (e.g. server-resident state).
request is borrowed from the request body and is valid for the
duration of the call; message fields are read directly on it
(zero-copy). The response cannot borrow from request — use
.to_owned_message() (or copy the specific fields) for anything
returned, stored, or moved into tokio::spawn.
Sourcefn update_api_policy<'a>(
&'a self,
ctx: RequestContext,
request: ServiceRequest<'_, UpdateApiPolicyRequest>,
) -> impl Future<Output = ServiceResult<impl Encodable<UpdateApiPolicyResponse> + Send + use<'a, Self>>> + Send
fn update_api_policy<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, UpdateApiPolicyRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<UpdateApiPolicyResponse> + Send + use<'a, Self>>> + Send
Change selected fields on an existing API key policy template.
'a lets the response body borrow from &self (e.g. server-resident state).
request is borrowed from the request body and is valid for the
duration of the call; message fields are read directly on it
(zero-copy). The response cannot borrow from request — use
.to_owned_message() (or copy the specific fields) for anything
returned, stored, or moved into tokio::spawn.
Sourcefn delete_api_policy<'a>(
&'a self,
ctx: RequestContext,
request: ServiceRequest<'_, DeleteApiPolicyRequest>,
) -> impl Future<Output = ServiceResult<impl Encodable<DeleteApiPolicyResponse> + Send + use<'a, Self>>> + Send
fn delete_api_policy<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, DeleteApiPolicyRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<DeleteApiPolicyResponse> + Send + use<'a, Self>>> + Send
Delete an API key policy template.
'a lets the response body borrow from &self (e.g. server-resident state).
request is borrowed from the request body and is valid for the
duration of the call; message fields are read directly on it
(zero-copy). The response cannot borrow from request — use
.to_owned_message() (or copy the specific fields) for anything
returned, stored, or moved into tokio::spawn.
Sourcefn set_api_key_policy<'a>(
&'a self,
ctx: RequestContext,
request: ServiceRequest<'_, SetApiKeyPolicyRequest>,
) -> impl Future<Output = ServiceResult<impl Encodable<SetApiKeyPolicyResponse> + Send + use<'a, Self>>> + Send
fn set_api_key_policy<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, SetApiKeyPolicyRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<SetApiKeyPolicyResponse> + Send + use<'a, Self>>> + Send
Attach or clear an API key policy for a key.
'a lets the response body borrow from &self (e.g. server-resident state).
request is borrowed from the request body and is valid for the
duration of the call; message fields are read directly on it
(zero-copy). The response cannot borrow from request — use
.to_owned_message() (or copy the specific fields) for anything
returned, stored, or moved into tokio::spawn.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".