pub enum By {
Person(String),
Session(Who),
SignIn(String),
Server,
Other,
}Expand description
Who caused a record: the caller of its command, with its class (01M3X4Z60G1FXQTDC5XDJ05BAX). It holds only the user and the session ID. The session in a change is a full URI, with the place.
| Caller | JSON |
|---|---|
| a person | {"person":"mike"} |
| a session | {"session":"mike/a6cf"} |
| a sign-in | {"sign_in":"mike@comotechnologies.io"} |
| the server | "server" |
The set of classes can grow. A build reads a class that it does not
know as By::Other.
use riff_core::name::Who;
use riff_core::record::By;
let session = By::Session(Who::new("mike", Some("a6cf"))?);
assert_eq!(serde_json::to_string(&session).unwrap(), r#"{"session":"mike/a6cf"}"#);
assert_eq!(serde_json::to_string(&By::Server).unwrap(), r#""server""#);
assert_eq!(session.to_string(), "the session mike/a6cf");
let read = |json: &str| serde_json::from_str::<By>(json).unwrap();
assert_eq!(read(r#"{"person":"mike"}"#), By::Person("mike".into()));
assert_eq!(read(r#"{"session":"mike/a6cf"}"#), session);
assert_eq!(read(r#""server""#), By::Server);
// A class of a later build.
assert_eq!(read(r#"{"robot":"r2"}"#), By::Other);
assert_eq!(read(r#""cron""#), By::Other);Variants§
Person(String)
A person, by the user.
Session(Who)
An agent session, by the user and the session ID.
SignIn(String)
A verified email of the provider, before a token is there.
Server
A timer of riff-server.
Other
A class that this build does not know.
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for By
impl<'de> Deserialize<'de> for By
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<By, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<By, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Source§impl JsonSchema for By
impl JsonSchema for By
Source§fn json_schema(_: &mut SchemaGenerator) -> Schema
fn json_schema(_: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreimpl Eq for By
impl StructuralPartialEq for By
Auto Trait Implementations§
impl Freeze for By
impl RefUnwindSafe for By
impl Send for By
impl Sync for By
impl Unpin for By
impl UnsafeUnpin for By
impl UnwindSafe for By
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
Mutably borrows from an owned value. Read more
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
Compare self to
key and return true if they are equal.