[−][src]Struct activitystreams::base::Base
A representation of the common fields between Links and Objects in ActivityStreams
Although the spec does not define a type more abstract that Object or Link, it does define fields present in both, so for the sake of "Everything derives from something," I've implemented a type.
Implementations
impl Base<Value>
[src]
pub fn solidify<Kind>(self) -> Result<Base<Kind>, Error> where
Kind: DeserializeOwned,
[src]
Kind: DeserializeOwned,
Convert this Base<serde_json::Value>
into a Base<Kind>
This is required before extending Base into the other types found in this crate
impl<Kind> Base<Kind>
[src]
pub fn new() -> Self where
Kind: Default,
[src]
Kind: Default,
Create a new Base
use activitystreams::base::Base; let base = Base::<String>::new();
pub fn extend<T>(self) -> Result<T, T::Error> where
T: Extends<Kind>,
[src]
T: Extends<Kind>,
Extend the Base into any other ActivityStreams type provided in this crate
let video = base.extend::<Video>()?;
pub fn retract<T>(t: T) -> Result<Self, T::Error> where
T: Extends<Kind>,
[src]
T: Extends<Kind>,
Retract any other ActivityStreams type into a Base<Kind>
let base = Base::retract(video)?;
pub fn into_generic(self) -> Result<Base<Value>, Error> where
Kind: Serialize,
[src]
Kind: Serialize,
Convert this Base into a Base<serde_json::Value>
This is required before putting a Base into an AnyBase type
pub fn map_kind<NewKind>(self, f: impl Fn(Kind) -> NewKind) -> Base<NewKind>
[src]
An inffalible conversion from Base<T>
to Base<U>
where there is a known path from T to
U
use activitystreams::{base::Base, prelude::*}; let mut base = Base::<String>::new(); base.set_kind("Hey".to_owned()); let new_base = base.map_kind(|kind| match kind.as_str() { "Create" => 1, "Update" => 5, _ => 0, }); assert!(*new_base.kind().unwrap() == 0);
pub fn try_map_kind<NewKind, E>(
self,
f: impl Fn(Kind) -> Result<NewKind, E>
) -> Result<Base<NewKind>, E>
[src]
self,
f: impl Fn(Kind) -> Result<NewKind, E>
) -> Result<Base<NewKind>, E>
A fallible conversion from Base<T> to Base<U>
use activitystreams::{base::Base, prelude::*}; let mut base = Base::<String>::new(); base.set_kind("Hey".to_owned()); let new_base = base.try_map_kind(|kind| match kind.as_str() { "Create" => Ok(1), "Update" => Ok(5), _ => Err(anyhow::Error::msg("invalid kind")), }); assert!(new_base.is_err());
Trait Implementations
impl<Kind> AsBase<Kind> for Base<Kind>
[src]
impl<Kind> Base for Base<Kind>
[src]
impl<Kind: Clone> Clone for Base<Kind>
[src]
impl<Kind: Debug> Debug for Base<Kind>
[src]
impl<'de, Kind> Deserialize<'de> for Base<Kind> where
Kind: Deserialize<'de>,
[src]
Kind: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl From<Base<Value>> for AnyBase
[src]
impl From<Base<Value>> for OneOrMany<AnyBase>
[src]
impl<Kind> Serialize for Base<Kind> where
Kind: Serialize,
[src]
Kind: Serialize,
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<Kind> TryFrom<Base<Kind>> for Link<Kind> where
Kind: DeserializeOwned,
[src]
Kind: DeserializeOwned,
type Error = Error
The type returned in the event of a conversion error.
fn try_from(base: Base<Kind>) -> Result<Self, Self::Error>
[src]
impl<Kind> TryFrom<Base<Kind>> for Object<Kind>
[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(base: Base<Kind>) -> Result<Self, Self::Error>
[src]
impl<Kind> TryFrom<Link<Kind>> for Base<Kind> where
Kind: Serialize,
[src]
Kind: Serialize,
type Error = Error
The type returned in the event of a conversion error.
fn try_from(link: Link<Kind>) -> Result<Self, Self::Error>
[src]
impl<Kind> TryFrom<Object<Kind>> for Base<Kind>
[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(object: Object<Kind>) -> Result<Self, Self::Error>
[src]
impl<Kind> UnparsedMut for Base<Kind>
[src]
fn unparsed_mut(&mut self) -> &mut Unparsed
[src]
Auto Trait Implementations
impl<Kind> RefUnwindSafe for Base<Kind> where
Kind: RefUnwindSafe,
Kind: RefUnwindSafe,
impl<Kind> Send for Base<Kind> where
Kind: Send,
Kind: Send,
impl<Kind> Sync for Base<Kind> where
Kind: Sync,
Kind: Sync,
impl<Kind> Unpin for Base<Kind> where
Kind: Unpin,
Kind: Unpin,
impl<Kind> UnwindSafe for Base<Kind> where
Kind: UnwindSafe,
Kind: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T, Kind> BaseExt<Kind> for T where
T: AsBase<Kind>,
[src]
T: AsBase<Kind>,
fn context<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>> where
Kind: 'a,
[src]
Kind: 'a,
fn set_context<T>(&mut self, context: T) -> &mut Self where
T: Into<AnyBase>,
[src]
T: Into<AnyBase>,
fn set_many_contexts<I, T>(&mut self, items: I) -> &mut Self where
I: IntoIterator<Item = T>,
T: Into<AnyBase>,
[src]
I: IntoIterator<Item = T>,
T: Into<AnyBase>,
fn add_context<T>(&mut self, context: T) -> &mut Self where
T: Into<AnyBase>,
[src]
T: Into<AnyBase>,
fn take_context(&mut self) -> Option<OneOrMany<AnyBase>>
[src]
fn delete_context(&mut self) -> &mut Self
[src]
fn id<'a>(&'a self, domain: &str) -> Result<Option<&'a Url>, DomainError> where
Kind: 'a,
[src]
Kind: 'a,
fn id_unchecked<'a>(&'a self) -> Option<&'a Url> where
Kind: 'a,
[src]
Kind: 'a,
fn id_mut<'a>(&'a mut self) -> Option<&'a mut Url> where
Kind: 'a,
[src]
Kind: 'a,
fn is_id(&self, id: &Url) -> bool
[src]
fn set_id(&mut self, id: Url) -> &mut Self
[src]
fn take_id(&mut self) -> Option<Url>
[src]
fn delete_id(&mut self) -> &mut Self
[src]
fn kind<'a>(&'a self) -> Option<&'a Kind> where
Kind: 'a,
[src]
Kind: 'a,
fn is_kind(&self, kind: &Kind) -> bool where
Kind: PartialEq,
[src]
Kind: PartialEq,
fn set_kind(&mut self, kind: Kind) -> &mut Self
[src]
fn take_kind(&mut self) -> Option<Kind>
[src]
fn delete_kind(&mut self) -> &mut Self
[src]
fn name<'a>(&'a self) -> Option<OneOrMany<&'a AnyString>> where
Kind: 'a,
[src]
Kind: 'a,
fn set_name<T>(&mut self, name: T) -> &mut Self where
T: Into<AnyString>,
[src]
T: Into<AnyString>,
fn set_many_names<I, T>(&mut self, items: I) -> &mut Self where
I: IntoIterator<Item = T>,
T: Into<AnyString>,
[src]
I: IntoIterator<Item = T>,
T: Into<AnyString>,
fn add_name<T>(&mut self, name: T) -> &mut Self where
T: Into<AnyString>,
[src]
T: Into<AnyString>,
fn take_name(&mut self) -> Option<OneOrMany<AnyString>>
[src]
fn delete_name(&mut self) -> &mut Self
[src]
fn media_type<'a>(&'a self) -> Option<&'a Mime> where
Kind: 'a,
[src]
Kind: 'a,
fn set_media_type(&mut self, media_type: Mime) -> &mut Self
[src]
fn take_media_type(&mut self) -> Option<Mime>
[src]
fn delete_media_type(&mut self) -> &mut Self
[src]
fn preview<'a>(&'a self) -> Option<OneOrMany<&'a AnyBase>> where
Kind: 'a,
[src]
Kind: 'a,
fn set_preview<T>(&mut self, preview: T) -> &mut Self where
T: Into<AnyBase>,
[src]
T: Into<AnyBase>,
fn set_many_previews<I, T>(&mut self, items: I) -> &mut Self where
I: IntoIterator<Item = T>,
T: Into<AnyBase>,
[src]
I: IntoIterator<Item = T>,
T: Into<AnyBase>,
fn add_preview<T>(&mut self, preview: T) -> &mut Self where
T: Into<AnyBase>,
[src]
T: Into<AnyBase>,
fn take_preview(&mut self) -> Option<OneOrMany<AnyBase>>
[src]
fn delete_preview(&mut self) -> &mut Self
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> UnparsedMutExt for T where
T: UnparsedMut,
[src]
T: UnparsedMut,