Skip to main content

Call

Trait Call 

Source
pub trait Call: Serialize + DeserializeOwned {
    type Reply: Serialize + DeserializeOwned;

    const PATH: &'static str;
}
Expand description

A call: one wire type with its path and the type of its reply (01M3WRD8TBDPA4JNEZY6J4N2EX). The client sends each call with one generic function, and the server makes one route for each.

use riff_core::wire::{Call, Claim};

/// The path of a call and the JSON of its body.
fn request<C: Call>(call: &C) -> (&'static str, String) {
    (C::PATH, serde_json::to_string(call).unwrap())
}

let claim = Claim {
    me: "riff://mike@pangolin/como-technologies/riff?session=a6cf".parse()?,
    thread: "como-technologies/riff".parse()?,
    item: "issue-12".into(),
};
let (path, body) = request(&claim);
assert_eq!(path, "/v1/claim");
assert!(body.contains("issue-12"));
let reply: <Claim as Call>::Reply = serde_json::from_str(
    r#"{"holder":"riff://mike@pangolin/como-technologies/riff?session=a6cf&claim=issue-12"}"#,
).unwrap();
assert_eq!(reply.holder.claims(), ["issue-12"]);

Required Associated Constants§

Source

const PATH: &'static str

The HTTP path of the call, for example /v1/claim.

Required Associated Types§

Source

type Reply: Serialize + DeserializeOwned

The reply to the call.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Call for Alive

Source§

const PATH: &'static str = "/v1/alive"

Source§

type Reply = AliveReply

Source§

impl Call for BlockedLook

Source§

const PATH: &'static str = "/v1/blocked/look"

Source§

type Reply = BlockedLookReply

Source§

impl Call for Claim

Source§

const PATH: &'static str = "/v1/claim"

Source§

type Reply = ClaimReply

Source§

impl Call for DenyOwner

Source§

const PATH: &'static str = "/v1/owner/deny"

Source§

type Reply = OwnerDenied

Source§

impl Call for End

Source§

const PATH: &'static str = "/v1/end"

Source§

type Reply = ()

Source§

impl Call for Free

Source§

const PATH: &'static str = "/v1/plan/free"

Source§

type Reply = FreeReply

Source§

impl Call for Hold

Source§

const PATH: &'static str = "/v1/plan/hold"

Source§

type Reply = HoldReply

Source§

impl Call for IdleQuery

Source§

const PATH: &'static str = "/v1/idle"

Source§

type Reply = Idle

Source§

impl Call for Invite

Source§

const PATH: &'static str = "/v1/invite"

Source§

type Reply = Invited

Source§

impl Call for ItemFacts

Source§

const PATH: &'static str = "/v1/items"

Source§

type Reply = ()

Source§

impl Call for Join

Source§

const PATH: &'static str = "/v1/join"

Source§

type Reply = ()

Source§

impl Call for Lead

Source§

const PATH: &'static str = "/v1/lead"

Source§

type Reply = LeadReply

Source§

impl Call for Leave

Source§

const PATH: &'static str = "/v1/leave"

Source§

type Reply = ()

Source§

impl Call for LogQuery

Source§

const PATH: &'static str = "/v1/log"

Source§

type Reply = LogReply

Source§

impl Call for Members

Source§

const PATH: &'static str = "/v1/members"

Source§

type Reply = MembersReply

Source§

impl Call for NotesShow

Source§

const PATH: &'static str = "/v1/notes"

Source§

type Reply = NotesReply

Source§

impl Call for PassOwner

Source§

const PATH: &'static str = "/v1/owner"

Source§

type Reply = OwnerPassed

Source§

impl Call for Pause

Source§

const PATH: &'static str = "/v1/pause"

Source§

type Reply = RiffReply

Source§

impl Call for PlanOff

Source§

const PATH: &'static str = "/v1/plan/off"

Source§

type Reply = PlanOffReply

Source§

impl Call for PlanSeen

Source§

const PATH: &'static str = "/v1/plan/seen"

Source§

type Reply = PlanReply

Source§

impl Call for PlanShow

Source§

const PATH: &'static str = "/v1/plan/show"

Source§

type Reply = PlanReply

Source§

impl Call for Post

Source§

const PATH: &'static str = "/v1/post"

Source§

type Reply = Posted

Source§

impl Call for Read

Source§

const PATH: &'static str = "/v1/read"

Source§

type Reply = ReadReply

Source§

impl Call for Register

Source§

const PATH: &'static str = "/v1/register"

Source§

type Reply = ()

Source§

impl Call for Release

Source§

const PATH: &'static str = "/v1/release"

Source§

type Reply = ReleaseReply

Source§

impl Call for ReleaseFor

Source§

const PATH: &'static str = "/v1/release/for"

Source§

type Reply = ()

Source§

impl Call for Remove

Source§

const PATH: &'static str = "/v1/remove"

Source§

type Reply = Removed

Source§

impl Call for Resume

Source§

const PATH: &'static str = "/v1/resume"

Source§

type Reply = RiffReply

Source§

impl Call for Revoke

Source§

const PATH: &'static str = "/v1/revoke"

Source§

type Reply = Revoked

Source§

impl Call for RiffQuery

Source§

const PATH: &'static str = "/v1/riff"

Source§

type Reply = RiffReply

Source§

impl Call for SetAdmin

Source§

const PATH: &'static str = "/v1/admin"

Source§

type Reply = AdminSet

Source§

impl Call for SetBlocked

Source§

const PATH: &'static str = "/v1/blocked"

Source§

type Reply = ()

Source§

impl Call for SetIdle

Source§

const PATH: &'static str = "/v1/idle/set"

Source§

type Reply = Idle

Source§

impl Call for SetMachine

Source§

const PATH: &'static str = "/v1/machine"

Source§

type Reply = ()

Source§

impl Call for SetNotes

Source§

const PATH: &'static str = "/v1/notes/set"

Source§

type Reply = SetNotesReply

Source§

impl Call for SetPlan

Source§

const PATH: &'static str = "/v1/plan"

Source§

type Reply = PlanReply

Source§

impl Call for SetStatus

Source§

const PATH: &'static str = "/v1/status"

Source§

type Reply = ()

Source§

impl Call for SetStep

Source§

const PATH: &'static str = "/v1/step"

Source§

type Reply = ()

Source§

impl Call for Start

Source§

const PATH: &'static str = "/v1/start"

Source§

type Reply = Started

Source§

impl Call for TakeOwner

Source§

const PATH: &'static str = "/v1/owner/take"

Source§

type Reply = OwnerAsked

Source§

impl Call for Threads

Source§

const PATH: &'static str = "/v1/threads"

Source§

type Reply = ThreadsReply

Source§

impl Call for WhoRequest

Source§

const PATH: &'static str = "/v1/who"

Source§

type Reply = WhoReply