pub struct Subject(/* private fields */);Expand description
A subject of EventSourcingDB, which is a path such as /books/42: it starts
with a slash, / alone is the root, and its segments are separated by
single slashes, none of them empty, each made only of the characters A-Z,
a-z, 0-9, underscores, and hyphens. A single slash at the end is taken, and
left out, as the database does, so /books/42/ is /books/42. A value
that is no such path can not be a subject at all.
A subject that is written in the code is made with
new, which panics for one that is not a subject. One that
comes from outside, such as a path in a request, is read with parse,
which refuses it with NotASubject, and one that is made of values from
outside is built with SubjectScheme::try_build:
use architecturekit::Subject;
let book = Subject::new("/books/42");
assert_eq!(book.as_str(), "/books/42");
let read: Subject = "/books/42/".parse()?;
assert_eq!(read, book);
assert!("books/42".parse::<Subject>().is_err());serde writes and reads a subject as a string.
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Subject
Reads the subject from a string, as parse does, and fails
with the text of NotASubject for a string that is not one.
impl<'de> Deserialize<'de> for Subject
Reads the subject from a string, as parse does, and fails
with the text of NotASubject for a string that is not one.
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
impl Eq for Subject
Source§impl FromStr for Subject
Reads a subject, and leaves out a single slash at its end.
impl FromStr for Subject
Reads a subject, and leaves out a single slash at its end.
§Errors
Fails with NotASubject for a value that does not start with a slash,
that has an empty segment, or a segment with a character the database does
not allow in a subject.
Source§impl Ord for Subject
impl Ord for Subject
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Subject
impl PartialOrd for Subject
impl StructuralPartialEq for Subject
Auto Trait Implementations§
impl Freeze for Subject
impl RefUnwindSafe for Subject
impl Send for Subject
impl Sync for Subject
impl Unpin for Subject
impl UnsafeUnpin for Subject
impl UnwindSafe for Subject
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request