Trait activitystreams::activity::QuestionExt
source · pub trait QuestionExt: AsQuestion {
Show 20 methods
fn one_of(&self) -> Option<&OneOrMany<AnyBase>> { ... }
fn set_one_of<T>(&mut self, one_of: T) -> &mut Self
where
T: Into<AnyBase>,
{ ... }
fn set_many_one_ofs<I, T>(&mut self, items: I) -> &mut Self
where
I: IntoIterator<Item = T>,
T: Into<AnyBase>,
{ ... }
fn add_one_of<T>(&mut self, one_of: T) -> &mut Self
where
T: Into<AnyBase>,
{ ... }
fn take_one_of(&mut self) -> Option<OneOrMany<AnyBase>> { ... }
fn delete_one_of(&mut self) -> &mut Self { ... }
fn any_of(&self) -> Option<&OneOrMany<AnyBase>> { ... }
fn set_any_of<T>(&mut self, any_of: T) -> &mut Self
where
T: Into<AnyBase>,
{ ... }
fn set_many_any_ofs<I, T>(&mut self, items: I) -> &mut Self
where
I: IntoIterator<Item = T>,
T: Into<AnyBase>,
{ ... }
fn add_any_of<T>(&mut self, any_of: T) -> &mut Self
where
T: Into<AnyBase>,
{ ... }
fn take_any_of(&mut self) -> Option<OneOrMany<AnyBase>> { ... }
fn delete_any_of(&mut self) -> &mut Self { ... }
fn closed(
&self
) -> Option<Either<&OneOrMany<AnyBase>, Either<OffsetDateTime, bool>>> { ... }
fn set_closed_base<T>(&mut self, closed: T) -> &mut Self
where
T: Into<AnyBase>,
{ ... }
fn set_many_closed_bases<I, T>(&mut self, closed: I) -> &mut Self
where
I: IntoIterator<Item = T>,
T: Into<AnyBase>,
{ ... }
fn set_closed_date(&mut self, closed: OffsetDateTime) -> &mut Self { ... }
fn set_closed_bool(&mut self, closed: bool) -> &mut Self { ... }
fn add_closed_base<T>(&mut self, closed: T) -> &mut Self
where
T: Into<AnyBase>,
{ ... }
fn take_closed(
&mut self
) -> Option<Either<OneOrMany<AnyBase>, Either<OffsetDateTime, bool>>> { ... }
fn delete_closed(&mut self) -> &mut Self { ... }
}
Expand description
Helper methods for interacting with Question types
This trait represents methods valid for an ActivityStreams Question
Documentation for the fields related to these methods can be found on the Question
struct
Provided Methods§
sourcefn one_of(&self) -> Option<&OneOrMany<AnyBase>>
fn one_of(&self) -> Option<&OneOrMany<AnyBase>>
Fetch the one_of field for the current activity
use activitystreams::prelude::*;
if let Some(one_of) = question.one_of() {
println!("{:?}", one_of);
}
sourcefn set_one_of<T>(&mut self, one_of: T) -> &mut Selfwhere
T: Into<AnyBase>,
fn set_one_of<T>(&mut self, one_of: T) -> &mut Selfwhere
T: Into<AnyBase>,
Set the one_of field for the current activity
This overwrites the contents of one_of
use activitystreams::prelude::*;
question.set_one_of(iri!("https://example.com"));
sourcefn set_many_one_ofs<I, T>(&mut self, items: I) -> &mut Selfwhere
I: IntoIterator<Item = T>,
T: Into<AnyBase>,
fn set_many_one_ofs<I, T>(&mut self, items: I) -> &mut Selfwhere
I: IntoIterator<Item = T>,
T: Into<AnyBase>,
Set many one_of items for the current activity
This overwrites the contents of one_of
use activitystreams::prelude::*;
question.set_many_one_ofs(vec![
iri!("https://example.com/one"),
iri!("https://example.com/two"),
]);
sourcefn add_one_of<T>(&mut self, one_of: T) -> &mut Selfwhere
T: Into<AnyBase>,
fn add_one_of<T>(&mut self, one_of: T) -> &mut Selfwhere
T: Into<AnyBase>,
Add a one_of to the current activity
This does not overwrite the contents of one_of, only appends an item
use activitystreams::prelude::*;
question
.add_one_of(iri!("https://example.com/one"))
.add_one_of(iri!("https://example.com/two"));
sourcefn take_one_of(&mut self) -> Option<OneOrMany<AnyBase>>
fn take_one_of(&mut self) -> Option<OneOrMany<AnyBase>>
Take the one_of field from the current activity, leaving nothing
use activitystreams::prelude::*;
if let Some(one_of) = question.take_one_of() {
println!("{:?}", one_of);
}
sourcefn delete_one_of(&mut self) -> &mut Self
fn delete_one_of(&mut self) -> &mut Self
Delete the one_of field from the current activity
use activitystreams::prelude::*;
assert!(question.one_of().is_some());
question.delete_one_of();
assert!(question.one_of().is_none());
sourcefn any_of(&self) -> Option<&OneOrMany<AnyBase>>
fn any_of(&self) -> Option<&OneOrMany<AnyBase>>
Fetch the any_of field for the current activity
use activitystreams::prelude::*;
if let Some(any_of) = question.any_of() {
println!("{:?}", any_of);
}
sourcefn set_any_of<T>(&mut self, any_of: T) -> &mut Selfwhere
T: Into<AnyBase>,
fn set_any_of<T>(&mut self, any_of: T) -> &mut Selfwhere
T: Into<AnyBase>,
Set the any_of field for the current activity
This overwrites the contents of any_of
use activitystreams::prelude::*;
question.set_any_of(iri!("https://example.com"));
sourcefn set_many_any_ofs<I, T>(&mut self, items: I) -> &mut Selfwhere
I: IntoIterator<Item = T>,
T: Into<AnyBase>,
fn set_many_any_ofs<I, T>(&mut self, items: I) -> &mut Selfwhere
I: IntoIterator<Item = T>,
T: Into<AnyBase>,
Set many any_of items for the current activity
This overwrites the contents of any_of
use activitystreams::prelude::*;
question.set_many_any_ofs(vec![
iri!("https://example.com/one"),
iri!("https://example.com/two"),
]);
sourcefn add_any_of<T>(&mut self, any_of: T) -> &mut Selfwhere
T: Into<AnyBase>,
fn add_any_of<T>(&mut self, any_of: T) -> &mut Selfwhere
T: Into<AnyBase>,
Add an any_of to the current activity
This does not overwrite the contents of any_of, only appends an item
use activitystreams::prelude::*;
question
.add_any_of(iri!("https://example.com/one"))
.add_any_of(iri!("https://example.com/two"));
sourcefn take_any_of(&mut self) -> Option<OneOrMany<AnyBase>>
fn take_any_of(&mut self) -> Option<OneOrMany<AnyBase>>
Take the any_of field from the current activity, leaving nothing
use activitystreams::prelude::*;
if let Some(any_of) = question.take_any_of() {
println!("{:?}", any_of);
}
sourcefn delete_any_of(&mut self) -> &mut Self
fn delete_any_of(&mut self) -> &mut Self
Delete the any_of field from the current activity
use activitystreams::prelude::*;
assert!(question.any_of().is_some());
question.delete_any_of();
assert!(question.any_of().is_none());
sourcefn closed(
&self
) -> Option<Either<&OneOrMany<AnyBase>, Either<OffsetDateTime, bool>>>
fn closed(
&self
) -> Option<Either<&OneOrMany<AnyBase>, Either<OffsetDateTime, bool>>>
Fetch the closed field for the current activity
use activitystreams::prelude::*;
if let Some(closed) = question.closed() {
println!("{:?}", closed);
}
sourcefn set_closed_base<T>(&mut self, closed: T) -> &mut Selfwhere
T: Into<AnyBase>,
fn set_closed_base<T>(&mut self, closed: T) -> &mut Selfwhere
T: Into<AnyBase>,
Set the closed field for the current activity
This overwrites the contents of any_of
use activitystreams::prelude::*;
question.set_closed_base(iri!("https://example.com/one"));
sourcefn set_many_closed_bases<I, T>(&mut self, closed: I) -> &mut Selfwhere
I: IntoIterator<Item = T>,
T: Into<AnyBase>,
fn set_many_closed_bases<I, T>(&mut self, closed: I) -> &mut Selfwhere
I: IntoIterator<Item = T>,
T: Into<AnyBase>,
Set many closed items for the current activity
This overwrites the contents of any_of
use activitystreams::prelude::*;
question.set_many_closed_bases(vec![
iri!("https://example.com/one"),
iri!("https://example.com/two"),
]);
sourcefn set_closed_date(&mut self, closed: OffsetDateTime) -> &mut Self
fn set_closed_date(&mut self, closed: OffsetDateTime) -> &mut Self
Set the closed field as a date
This overwrites the contents of any_of
use activitystreams::prelude::*;
question.set_closed_date(time::OffsetDateTime::now_utc());
sourcefn set_closed_bool(&mut self, closed: bool) -> &mut Self
fn set_closed_bool(&mut self, closed: bool) -> &mut Self
Set the closed field as a boolean
This overwrites the contents of any_of
use activitystreams::prelude::*;
question.set_closed_bool(true);
sourcefn add_closed_base<T>(&mut self, closed: T) -> &mut Selfwhere
T: Into<AnyBase>,
fn add_closed_base<T>(&mut self, closed: T) -> &mut Selfwhere
T: Into<AnyBase>,
Add an object or link to the closed field
This overwrites the contents of any_of
use activitystreams::prelude::*;
question
.add_closed_base(iri!("https://example.com/one"))
.add_closed_base(iri!("https://example.com/two"));
sourcefn take_closed(
&mut self
) -> Option<Either<OneOrMany<AnyBase>, Either<OffsetDateTime, bool>>>
fn take_closed(
&mut self
) -> Option<Either<OneOrMany<AnyBase>, Either<OffsetDateTime, bool>>>
Take the closed field from the current activity
use activitystreams::prelude::*;
if let Some(closed) = question.take_closed() {
println!("{:?}", closed);
}
sourcefn delete_closed(&mut self) -> &mut Self
fn delete_closed(&mut self) -> &mut Self
Remove the closed field from the current activity
use activitystreams::prelude::*;
assert!(question.closed().is_some());
question.delete_closed();
assert!(question.closed().is_none());