Struct mastodon_async::status_builder::StatusBuilder
source · pub struct StatusBuilder { /* private fields */ }
Expand description
A builder pattern struct for constructing a status.
// Example
use mastodon_async::{Language, StatusBuilder};
let status = StatusBuilder::new()
.status("a status")
.sensitive(true)
.spoiler_text("a CW")
.language(Language::Eng)
.build().unwrap();
Implementations§
source§impl StatusBuilder
impl StatusBuilder
sourcepub fn new() -> StatusBuilder
pub fn new() -> StatusBuilder
Create a StatusBuilder object
// Example
use mastodon_async::{entities::visibility::Visibility, prelude::*};
let data = Data::default();
let client = Mastodon::from(data);
let status = StatusBuilder::new()
.status("a status")
.visibility(Visibility::Public)
.build()
.unwrap();
tokio_test::block_on(async {
client.new_status(status).await.unwrap();
});
sourcepub fn status<I: Into<String>>(&mut self, status: I) -> &mut Self
pub fn status<I: Into<String>>(&mut self, status: I) -> &mut Self
Set the text for the post
// Example
use mastodon_async::prelude::*;
let status = StatusBuilder::new().status("awoooooo").build().unwrap();
sourcepub fn in_reply_to<I: Into<String>>(&mut self, id: I) -> &mut Self
pub fn in_reply_to<I: Into<String>>(&mut self, id: I) -> &mut Self
Set the in_reply_to_id for the post
// Example
use mastodon_async::prelude::*;
let status = StatusBuilder::new()
.status("awooooo")
.in_reply_to("12345")
.build()
.unwrap();
sourcepub fn media_ids<S: Display, I: IntoIterator<Item = S>>(
&mut self,
ids: I
) -> &mut Self
pub fn media_ids<S: Display, I: IntoIterator<Item = S>>( &mut self, ids: I ) -> &mut Self
Set the media_ids for the post
// Example
use mastodon_async::prelude::*;
let status = StatusBuilder::new().media_ids(&["foo", "bar"]).build().unwrap();
sourcepub fn spoiler_text<I: Into<String>>(&mut self, spoiler_text: I) -> &mut Self
pub fn spoiler_text<I: Into<String>>(&mut self, spoiler_text: I) -> &mut Self
Set the sensitive attribute for the post
// Example
use mastodon_async::prelude::*;
let status = StatusBuilder::new()
.media_ids(&["foo", "bar"])
.sensitive(true)
.build()
.unwrap();
sourcepub fn content_type<I: Into<String>>(&mut self, content_type: I) -> &mut Self
pub fn content_type<I: Into<String>>(&mut self, content_type: I) -> &mut Self
Set the content type of the post
This is a Pleroma and Glitch-soc extension of the API.
// Possible values
text/plain
text/html
text/markdown
text/bbcode
(Pleroma only)
The set of supported content types may vary by server.
// Example
use mastodon_async::prelude::*;
let status = StatusBuilder::new()
.status("<b>thicc</b>")
.content_type("text/html")
.build()
.unwrap();
sourcepub fn visibility(&mut self, visibility: Visibility) -> &mut Self
pub fn visibility(&mut self, visibility: Visibility) -> &mut Self
Set the visibility for the post
// Example
use mastodon_async::{prelude::*, entities::visibility::Visibility};
let status = StatusBuilder::new()
.status("awooooooo")
.visibility(Visibility::Public)
.build()
.unwrap();
sourcepub fn language(&mut self, language: Language) -> &mut Self
pub fn language(&mut self, language: Language) -> &mut Self
Set the language for the post
// Example
use mastodon_async::{Language, prelude::*};
let status = StatusBuilder::new()
.status("awoo!!!!")
.language(Language::Eng)
.build()
.unwrap();
Trait Implementations§
source§impl Clone for StatusBuilder
impl Clone for StatusBuilder
source§fn clone(&self) -> StatusBuilder
fn clone(&self) -> StatusBuilder
Returns a copy 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 StatusBuilder
impl Debug for StatusBuilder
source§impl Default for StatusBuilder
impl Default for StatusBuilder
source§fn default() -> StatusBuilder
fn default() -> StatusBuilder
Returns the “default value” for a type. Read more
source§impl PartialEq for StatusBuilder
impl PartialEq for StatusBuilder
source§fn eq(&self, other: &StatusBuilder) -> bool
fn eq(&self, other: &StatusBuilder) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Eq for StatusBuilder
impl StructuralPartialEq for StatusBuilder
Auto Trait Implementations§
impl RefUnwindSafe for StatusBuilder
impl Send for StatusBuilder
impl Sync for StatusBuilder
impl Unpin for StatusBuilder
impl UnwindSafe for StatusBuilder
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
§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
Checks if this value is equivalent to the given key. Read more
§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.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
Compare self to
key
and return true
if they are equal.