Skip to main content

LayoutService

Trait LayoutService 

Source
pub trait LayoutService:
    Send
    + Sync
    + 'static {
Show 15 methods // Required methods fn get_layouts<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, GetLayoutsRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<GetLayoutsResponse> + Send + use<'a, Self>>> + Send; fn get_layout<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, GetLayoutRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<GetLayoutResponse> + Send + use<'a, Self>>> + Send; fn upsert_layout<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, UpsertLayoutRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<UpsertLayoutResponse> + Send + use<'a, Self>>> + Send; fn delete_layout<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, DeleteLayoutRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<DeleteLayoutResponse> + Send + use<'a, Self>>> + Send; fn resolve_layout_share_token<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, ResolveLayoutShareTokenRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<ResolveLayoutShareTokenResponse> + Send + use<'a, Self>>> + Send; fn create_layout_share_link<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, CreateLayoutShareLinkRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<CreateLayoutShareLinkResponse> + Send + use<'a, Self>>> + Send; fn revoke_layout_share_link<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, RevokeLayoutShareLinkRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<RevokeLayoutShareLinkResponse> + Send + use<'a, Self>>> + Send; fn list_owner_published_layouts<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, ListOwnerPublishedLayoutsRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<ListOwnerPublishedLayoutsResponse> + Send + use<'a, Self>>> + Send; fn publish_layout<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, PublishLayoutRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<PublishLayoutResponse> + Send + use<'a, Self>>> + Send; fn unpublish_layout<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, UnpublishLayoutRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<UnpublishLayoutResponse> + Send + use<'a, Self>>> + Send; fn list_layout_template_versions<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, ListLayoutTemplateVersionsRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<ListLayoutTemplateVersionsResponse> + Send + use<'a, Self>>> + Send; fn get_layout_template_version<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, GetLayoutTemplateVersionRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<GetLayoutTemplateVersionResponse> + Send + use<'a, Self>>> + Send; fn set_layout_template_subscription<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, SetLayoutTemplateSubscriptionRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<SetLayoutTemplateSubscriptionResponse> + Send + use<'a, Self>>> + Send; fn delete_layout_template_subscription<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, DeleteLayoutTemplateSubscriptionRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<DeleteLayoutTemplateSubscriptionResponse> + Send + use<'a, Self>>> + Send; fn list_my_layout_template_subscriptions<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, ListMyLayoutTemplateSubscriptionsRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<ListMyLayoutTemplateSubscriptionsResponse> + Send + use<'a, Self>>> + Send;
}
Expand description

LayoutService persists saved layouts and manages public layout sharing.

§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 get_layouts<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, GetLayoutsRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<GetLayoutsResponse> + Send + use<'a, Self>>> + Send

GetLayouts returns the caller’s saved layouts.

'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 get_layout<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, GetLayoutRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<GetLayoutResponse> + Send + use<'a, Self>>> + Send

GetLayout returns a single layout 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.

Source

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

UpsertLayout creates or updates a layout (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 delete_layout<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, DeleteLayoutRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<DeleteLayoutResponse> + Send + use<'a, Self>>> + Send

DeleteLayout deletes a layout by id (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 resolve_layout_share_token<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, ResolveLayoutShareTokenRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<ResolveLayoutShareTokenResponse> + Send + use<'a, Self>>> + Send

ResolveLayoutShareToken resolves an unauthenticated share token to a layout snapshot (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.

CreateLayoutShareLink mints a share token for a layout (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.

RevokeLayoutShareLink revokes a previously minted share token (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_owner_published_layouts<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, ListOwnerPublishedLayoutsRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<ListOwnerPublishedLayoutsResponse> + Send + use<'a, Self>>> + Send

ListOwnerPublishedLayouts lists listed/published layouts for an owner (profile/gallery surfaces).

'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 publish_layout<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, PublishLayoutRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<PublishLayoutResponse> + Send + use<'a, Self>>> + Send

PublishLayout publishes a layout for discovery (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 unpublish_layout<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, UnpublishLayoutRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<UnpublishLayoutResponse> + Send + use<'a, Self>>> + Send

UnpublishLayout removes a layout from discovery (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_layout_template_versions<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, ListLayoutTemplateVersionsRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<ListLayoutTemplateVersionsResponse> + Send + use<'a, Self>>> + Send

List available versions for a template (metadata 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 get_layout_template_version<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, GetLayoutTemplateVersionRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<GetLayoutTemplateVersionResponse> + Send + use<'a, Self>>> + Send

Get a specific version snapshot for a 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.

Source

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

Subscribe (follow) a template (pin version or track latest).

'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 delete_layout_template_subscription<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, DeleteLayoutTemplateSubscriptionRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<DeleteLayoutTemplateSubscriptionResponse> + Send + use<'a, Self>>> + Send

DeleteLayoutTemplateSubscription unfollows a layout template for 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 list_my_layout_template_subscriptions<'a>( &'a self, ctx: RequestContext, request: ServiceRequest<'_, ListMyLayoutTemplateSubscriptionsRequest>, ) -> impl Future<Output = ServiceResult<impl Encodable<ListMyLayoutTemplateSubscriptionsResponse> + Send + use<'a, Self>>> + Send

ListMyLayoutTemplateSubscriptions lists layout templates followed by 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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§