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

source

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();
});
source

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();
source

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();
source

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();
source

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();
source

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();
source

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();
source

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();
source

pub fn sensitive(&mut self, flag: bool) -> &mut Self

Set the status as “sensitive”.

use mastodon_async::StatusBuilder;

let status = StatusBuilder::new()
    .status("a sensitive matter")
    .sensitive(true)
    .build()
    .unwrap();
source

pub fn build(&self) -> Result<NewStatus, Error>

Constructs a NewStatus

// Example

use mastodon_async::prelude::*;
let status = StatusBuilder::new().status("awoo!").build().unwrap();

Trait Implementations§

source§

impl Clone for StatusBuilder

source§

fn clone(&self) -> StatusBuilder

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for StatusBuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for StatusBuilder

source§

fn default() -> StatusBuilder

Returns the “default value” for a type. Read more
source§

impl PartialEq for StatusBuilder

source§

fn eq(&self, other: &StatusBuilder) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for StatusBuilder

source§

impl StructuralPartialEq for StatusBuilder

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

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
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

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
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more