pub struct SessionUri { /* private fields */ }Expand description
The URI of one session: who, where and what.
It serializes as its full URI. Two URIs of one session differ when the session moves or claims.
use riff_core::name::SessionUri;
let text = "riff://mike@pangolin/como-technologies/riff?session=a6cf&claim=issue-6#pr-23";
let uri: SessionUri = text.parse()?;
assert_eq!(uri.to_string(), text);
assert_eq!(uri.short(), "mike@pangolin:riff#pr-23");
assert_eq!(uri.who().session(), Some("a6cf"));
assert_eq!(uri.claims(), ["issue-6"]);
assert!(!uri.lead());
let lead: SessionUri = "riff://mike@pangolin/como-technologies/riff?session=a6cf&lead=true".parse()?;
assert!(lead.lead());§A query part of a later build (01M3XYYSY536AEJVERBPTQFQYX)
The set of query parts can grow, as lead and claim came. A URI
in JSON keeps each query part that this build does not know
(SessionUri::other), as it came. The session is the same
session: its user, its session ID and its place. The part gives no
mark: no lead and no claim. A URI that a person types
(FromStr) takes only the parts of this build, and
riff-server refuses a call of a caller with such a part.
use riff_core::name::SessionUri;
let known: SessionUri = "riff://ann@heron/acme/app?session=s1".parse()?;
let json = r#""riff://ann@heron/acme/app?session=s1&wave=17&lead=maybe""#;
let later: SessionUri = serde_json::from_str(json).unwrap();
assert_eq!((later.who(), later.place()), (known.who(), known.place()));
assert!(later.is_other() && !later.lead() && later.claims().is_empty());
assert_eq!(later.other(), ["wave=17", "lead=maybe"]);
assert_eq!(serde_json::to_string(&later).unwrap(), json);
assert!(json.trim_matches('"').parse::<SessionUri>().is_err());Implementations§
Source§impl SessionUri
impl SessionUri
Sourcepub fn with_claims(self, claims: Vec<String>) -> Self
pub fn with_claims(self, claims: Vec<String>) -> Self
The same URI with these claims, in sorted order.
pub fn who(&self) -> &Who
pub fn place(&self) -> &Place
pub fn claims(&self) -> &[String]
Sourcepub fn short(&self) -> String
pub fn short(&self) -> String
The short form for people: USER@HOST:REPO#WORKTREE.
let main: SessionUri = "riff://mike@pangolin/como-technologies/riff?session=a6cf".parse()?;
assert_eq!(main.short(), "mike@pangolin:riff");
let notes: SessionUri = "riff://mike@pangolin/-?session=a6cf#notes".parse()?;
assert_eq!(notes.short(), "mike@pangolin:-#notes");
let person: SessionUri = "riff://mike@pangolin".parse()?;
assert_eq!(person.short(), "mike@pangolin");Sourcepub fn default_thread(&self) -> Option<ThreadName>
pub fn default_thread(&self) -> Option<ThreadName>
The thread that this session joins by default: OWNER/REPO.
Trait Implementations§
Source§impl Clone for SessionUri
impl Clone for SessionUri
Source§fn clone(&self) -> SessionUri
fn clone(&self) -> SessionUri
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SessionUri
impl Debug for SessionUri
Source§impl<'de> Deserialize<'de> for SessionUri
impl<'de> Deserialize<'de> for SessionUri
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for SessionUri
impl Display for SessionUri
Source§impl From<SessionUri> for String
impl From<SessionUri> for String
Source§fn from(uri: SessionUri) -> Self
fn from(uri: SessionUri) -> Self
Converts to this type from the input type.
Source§impl FromStr for SessionUri
impl FromStr for SessionUri
Source§impl Hash for SessionUri
impl Hash for SessionUri
Source§impl JsonSchema for SessionUri
impl JsonSchema for SessionUri
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 moreSource§impl Ord for SessionUri
impl Ord for SessionUri
Source§fn cmp(&self, other: &SessionUri) -> Ordering
fn cmp(&self, other: &SessionUri) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for SessionUri
impl PartialEq for SessionUri
Source§impl PartialOrd for SessionUri
impl PartialOrd for SessionUri
Source§impl Serialize for SessionUri
impl Serialize for SessionUri
Source§impl TryFrom<String> for SessionUri
impl TryFrom<String> for SessionUri
impl Eq for SessionUri
impl StructuralPartialEq for SessionUri
Auto Trait Implementations§
impl Freeze for SessionUri
impl RefUnwindSafe for SessionUri
impl Send for SessionUri
impl Sync for SessionUri
impl Unpin for SessionUri
impl UnsafeUnpin for SessionUri
impl UnwindSafe for SessionUri
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> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§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.