pub enum Kind {
Message,
Status,
Note,
Riff,
Other,
}Expand description
The kind of a post. A post call sends message, status or
note.
use riff_core::wire::Kind;
assert_eq!(serde_json::to_string(&Kind::Status).unwrap(), r#""status""#);
assert_eq!("status".parse::<Kind>(), Ok(Kind::Status));
assert_eq!(serde_json::to_string(&Kind::Note).unwrap(), r#""note""#);
assert_eq!("note".parse::<Kind>(), Ok(Kind::Note));
assert!("other".parse::<Kind>().is_err());
assert!(Kind::Note.needs_body() && !Kind::Status.needs_body());Variants§
Message
A message to read.
Status
A status request. Each session that it wakes sets its status
with status. It does not post a reply.
Note
A note: it informs and wakes no session. A session sees it at its
next read (01M3JPMQE6S7YM4HPEVGXWK7ET).
Riff
A message that riff itself writes, as the person of the riff: the
watch of a deploy, the daemon, the lines of riff release. It
reads and wakes as a message. It never counts as the word of a
person (Kind::by_riff). A session has no use for it, so a
schema of a call does not list it.
Other
A kind that this build does not know. A reader shows the post as a message.
Implementations§
Source§impl Kind
impl Kind
pub fn is_message(&self) -> bool
Sourcepub fn by_riff(&self) -> bool
pub fn by_riff(&self) -> bool
True for the kind of a line that riff writes, not a person:
Kind::Riff.
use riff_core::wire::Kind;
assert!(Kind::Riff.by_riff());
assert!(![Kind::Message, Kind::Status, Kind::Note, Kind::Other].iter().any(Kind::by_riff));Sourcepub fn needs_body(&self) -> bool
pub fn needs_body(&self) -> bool
True when a post of this kind needs a body. Only a status request needs none.
Sourcepub fn is_post(&self) -> bool
pub fn is_post(&self) -> bool
True for a kind that a post call can have. A kind of a later
build reads as Kind::Other, and no post call can have it
(01M3XSF90E9JYYTC13D9THY4WE).
use riff_core::wire::Kind;
let read = |json: &str| serde_json::from_str::<Kind>(json).unwrap();
assert_eq!(read(r#""note""#), Kind::Note);
// The kind of a line of riff has a name in JSON, and none for a person.
assert_eq!(read(r#""riff""#), Kind::Riff);
assert_eq!(serde_json::to_string(&Kind::Riff).unwrap(), r#""riff""#);
assert!("riff".parse::<Kind>().is_err());
// A kind of a later build can have each form of JSON.
for later in [r#""poll""#, r#"{"poll":"wave"}"#, "7", "null"] {
assert_eq!(read(later), Kind::Other, "{later}");
}
assert!(Kind::Note.is_post() && Kind::Riff.is_post() && !Kind::Other.is_post());
assert_eq!(serde_json::to_string(&Kind::Other).unwrap(), r#""other""#);
// The schema of a call has only the kinds of a `post` call.
let schema = serde_json::to_value(schemars::schema_for!(Kind)).unwrap();
let kinds: Vec<&str> = schema["oneOf"]
.as_array()
.unwrap()
.iter()
.map(|kind| kind["const"].as_str().unwrap())
.collect();
assert_eq!(kinds, ["message", "status", "note"]);Trait Implementations§
Source§impl<'de> Deserialize<'de> for Kind
The set of kinds can grow. A build reads each value that it does not
know as Kind::Other: a text, and each other form of JSON
(01M3XSF90E9JYYTC13D9THY4WE). The kind Kind::Riff has a name in
JSON but not in FromStr: a person types no
such kind.
impl<'de> Deserialize<'de> for Kind
The set of kinds can grow. A build reads each value that it does not
know as Kind::Other: a text, and each other form of JSON
(01M3XSF90E9JYYTC13D9THY4WE). The kind Kind::Riff has a name in
JSON but not in FromStr: a person types no
such kind.
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl JsonSchema for Kind
impl JsonSchema for Kind
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreimpl Copy for Kind
impl Eq for Kind
impl StructuralPartialEq for Kind
Auto Trait Implementations§
impl Freeze for Kind
impl RefUnwindSafe for Kind
impl Send for Kind
impl Sync for Kind
impl Unpin for Kind
impl UnsafeUnpin for Kind
impl UnwindSafe for Kind
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.