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
impl PastebinClient
Sourcepub fn with_token(token: &str) -> Result<Self>
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_).
Sourcepub fn with_delete_token(paste_id: &str, token: &str) -> Result<Self>
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.
Sourcepub fn create_paste(&self, request: CreatePasteRequest) -> Result<PasteCreated>
pub fn create_paste(&self, request: CreatePasteRequest) -> Result<PasteCreated>
Create a new paste.
Returns PasteCreated with the paste URL, raw URL, and delete token.
Sourcepub fn get_paste(&self, id: &str) -> Result<Paste>
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.
Sourcepub fn list_pastes(&self, limit: usize) -> Result<Vec<Paste>>
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.
Sourcepub fn delete_paste(&self, id: &str) -> Result<()>
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.