pub struct Author {
pub shareable: Option<bool>,
/* private fields */
}
Expand description
Object that represents an Author of the Cocktail
data base.
§Description
Authors’ main role is defining recipes in the data base, and own them until they delete them or transfer the ownership. This object is a simple descriptor that includes some personal information of the authors.
All attributes are optional to allow using this struct
as query object for the GET methods of the /author
endpoint. Mandatory fields are defined in the description of each method of the endpoint.
Some restrictions over the struct
’s members:
- Author::id must contain a valid Uuid. Strings are parsed to Uuid. The expected format is a 128-bit value, formatted as a hex string in five groups. The first 4 groups are randomly generated, and the fifth comes from a timestamp. However, clients can freely generate this ID using other combinations as long as the length and basic format rules are honored.
- Author::name and Author::surname shall have a minimum length of 2 and a maximum of 40 characters. These fields are allowed to repeat in the DB. Authors are identified in the DB by Author::id. Usernames are not required.
- Author::email is validated against the HTML5 regex.
- Author::description can’t exceed 255 characters length.
- Author::website must contain an url format (
http://...
orhttps://...
).
Authors are given the choice to share or keep private their profiles. Activate Author::shareable to allow sharing the author’s profile to the main public. Private profiles are protected from non privileged clients of the API (with no API access token): only the Author::id and Author::name is given when a unprivileged client requests the data of an author to the API.
The constructor Author::default is given to generate a new author entry using a random funny name.
Prefer AuthorBuilder rather than Author::new to build a new Author instance.
Fields§
Decide whether an author profile can be shared to the public or not.
Implementations§
Source§impl Author
impl Author
Sourcepub fn new(
id: Option<String>,
name: Option<String>,
surname: Option<String>,
email: Option<String>,
shareable: Option<bool>,
description: Option<String>,
website: Option<String>,
social_profiles: Option<&[SocialProfile]>,
) -> Result<Self, DataDomainError>
pub fn new( id: Option<String>, name: Option<String>, surname: Option<String>, email: Option<String>, shareable: Option<bool>, description: Option<String>, website: Option<String>, social_profiles: Option<&[SocialProfile]>, ) -> Result<Self, DataDomainError>
pub fn id(&self) -> Option<String>
pub fn name(&self) -> Option<&str>
pub fn surname(&self) -> Option<&str>
pub fn email(&self) -> Option<&str>
pub fn description(&self) -> Option<&str>
pub fn website(&self) -> Option<&str>
pub fn mute_private_data(&mut self)
pub fn enable_sharing(&mut self)
pub fn disable_sharing(&mut self)
Sourcepub fn update_from(&mut self, update: &Author)
pub fn update_from(&mut self, update: &Author)
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Author
impl<'de> Deserialize<'de> for Author
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>,
Auto Trait Implementations§
impl Freeze for Author
impl RefUnwindSafe for Author
impl Send for Author
impl Sync for Author
impl Unpin for Author
impl UnwindSafe for Author
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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more