Skip to main content

SubaccountService

Trait SubaccountService 

Source
pub trait SubaccountService:
    Send
    + Sync
    + 'static {
    // Required methods
    fn list_subaccounts<'a>(
        &'a self,
        ctx: RequestContext,
        request: ServiceRequest<'_, ListSubaccountsRequest>,
    ) -> impl Future<Output = ServiceResult<impl Encodable<ListSubaccountsResponse> + Send + use<'a, Self>>> + Send;
    fn create_subaccount<'a>(
        &'a self,
        ctx: RequestContext,
        request: ServiceRequest<'_, CreateSubaccountRequest>,
    ) -> impl Future<Output = ServiceResult<impl Encodable<CreateSubaccountResponse> + Send + use<'a, Self>>> + Send;
    fn update_subaccount<'a>(
        &'a self,
        ctx: RequestContext,
        request: ServiceRequest<'_, UpdateSubaccountRequest>,
    ) -> impl Future<Output = ServiceResult<impl Encodable<UpdateSubaccountResponse> + Send + use<'a, Self>>> + Send;
    fn set_subaccount_member_mfa_requirement<'a>(
        &'a self,
        ctx: RequestContext,
        request: ServiceRequest<'_, SetSubaccountMemberMFARequirementRequest>,
    ) -> impl Future<Output = ServiceResult<impl Encodable<SetSubaccountMemberMFARequirementResponse> + Send + use<'a, Self>>> + Send;
    fn list_subaccount_members<'a>(
        &'a self,
        ctx: RequestContext,
        request: ServiceRequest<'_, ListSubaccountMembersRequest>,
    ) -> impl Future<Output = ServiceResult<impl Encodable<ListSubaccountMembersResponse> + Send + use<'a, Self>>> + Send;
    fn remove_subaccount_member<'a>(
        &'a self,
        ctx: RequestContext,
        request: ServiceRequest<'_, RemoveSubaccountMemberRequest>,
    ) -> impl Future<Output = ServiceResult<impl Encodable<RemoveSubaccountMemberResponse> + Send + use<'a, Self>>> + Send;
    fn update_subaccount_member_role<'a>(
        &'a self,
        ctx: RequestContext,
        request: ServiceRequest<'_, UpdateSubaccountMemberRoleRequest>,
    ) -> impl Future<Output = ServiceResult<impl Encodable<UpdateSubaccountMemberRoleResponse> + Send + use<'a, Self>>> + Send;
    fn invite_subaccount_member<'a>(
        &'a self,
        ctx: RequestContext,
        request: ServiceRequest<'_, InviteSubaccountMemberRequest>,
    ) -> impl Future<Output = ServiceResult<impl Encodable<InviteSubaccountMemberResponse> + Send + use<'a, Self>>> + Send;
    fn list_subaccount_invites<'a>(
        &'a self,
        ctx: RequestContext,
        request: ServiceRequest<'_, ListSubaccountInvitesRequest>,
    ) -> impl Future<Output = ServiceResult<impl Encodable<ListSubaccountInvitesResponse> + Send + use<'a, Self>>> + Send;
    fn respond_subaccount_invite<'a>(
        &'a self,
        ctx: RequestContext,
        request: ServiceRequest<'_, RespondSubaccountInviteRequest>,
    ) -> impl Future<Output = ServiceResult<impl Encodable<RespondSubaccountInviteResponse> + Send + use<'a, Self>>> + Send;
}
Expand description

Service for creating, updating, sharing, and listing sub-accounts.

§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§

Source

fn list_subaccounts<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, ListSubaccountsRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<ListSubaccountsResponse> + Send + use<'a, Self>>> + Send

List sub-accounts owned by or shared with 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.

Source

fn create_subaccount<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, CreateSubaccountRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<CreateSubaccountResponse> + Send + use<'a, Self>>> + Send

Create a new sub-account under the caller’s root 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.

Source

fn update_subaccount<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, UpdateSubaccountRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<UpdateSubaccountResponse> + Send + use<'a, Self>>> + Send

Update mutable sub-account fields (label/status/icon/color).

'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.

Source

fn set_subaccount_member_mfa_requirement<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, SetSubaccountMemberMFARequirementRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<SetSubaccountMemberMFARequirementResponse> + Send + use<'a, Self>>> + Send

Toggle the delegated member MFA requirement for one sub-account (owner only).

'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.

Source

fn list_subaccount_members<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, ListSubaccountMembersRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<ListSubaccountMembersResponse> + Send + use<'a, Self>>> + Send

List members for a sub-account (owner/admin only).

'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.

Source

fn remove_subaccount_member<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, RemoveSubaccountMemberRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<RemoveSubaccountMemberResponse> + Send + use<'a, Self>>> + Send

Remove a member from a sub-account (owner/admin only).

'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.

Source

fn update_subaccount_member_role<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, UpdateSubaccountMemberRoleRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<UpdateSubaccountMemberRoleResponse> + Send + use<'a, Self>>> + Send

Update an existing sub-account member’s role (owner/admin only).

'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.

Source

fn invite_subaccount_member<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, InviteSubaccountMemberRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<InviteSubaccountMemberResponse> + Send + use<'a, Self>>> + Send

Invite a member 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.

Source

fn list_subaccount_invites<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, ListSubaccountInvitesRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<ListSubaccountInvitesResponse> + Send + use<'a, Self>>> + Send

List incoming/outgoing sub-account invitations.

'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.

Source

fn respond_subaccount_invite<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, RespondSubaccountInviteRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<RespondSubaccountInviteResponse> + Send + use<'a, Self>>> + Send

Accept/decline an invite (grantee) or cancel an invite (inviter).

'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".

Implementors§