Skip to main content

PastebinClient

Struct PastebinClient 

Source
pub struct PastebinClient { /* private fields */ }
Expand description

HTTP client for the pastebin.ai API.

Supports both anonymous and authenticated operations. Use new() for anonymous access, with_token() for authenticated access, or with_delete_token() to delete an anonymous paste using its delete token.

Implementations§

Source§

impl PastebinClient

Source

pub fn new() -> Result<Self>

Create a new anonymous client.

Source

pub fn with_token(token: &str) -> Result<Self>

Create an authenticated client with a Bearer token.

Get your token from https://pastebin.ai/settings/api (starts with pba_).

Source

pub fn with_delete_token(paste_id: &str, token: &str) -> Result<Self>

Create a client for deleting a specific anonymous paste.

Use the delete token returned when creating the paste.

Source

pub fn create_paste(&self, request: CreatePasteRequest) -> Result<PasteCreated>

Create a new paste.

Returns PasteCreated with the paste URL, raw URL, and delete token.

Source

pub fn get_paste(&self, id: &str) -> Result<Paste>

Retrieve a paste by ID.

Works for public and unlisted pastes. Private/password-protected/encrypted pastes require authentication and return 404.

Source

pub fn list_pastes(&self, limit: usize) -> Result<Vec<Paste>>

List pastes owned by the authenticated account.

Requires authentication via with_token(). Returns up to limit pastes.

Source

pub fn delete_paste(&self, id: &str) -> Result<()>

Delete a paste.

For anonymous pastes created with this client’s delete token, uses the public delete endpoint with X-Delete-Token header. For authenticated pastes, uses the account endpoint with Bearer token.

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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.