pub struct UnauthenticatedClient { /* private fields */ }Expand description
API client to perform unauthenticated requests to the pasty API.
§Reference
Implementation according to the pasty API documentation: https://github.com/lus/pasty/blob/master/API.md#api
Implementations§
Source§impl UnauthenticatedClient
impl UnauthenticatedClient
Sourcepub fn new(host: impl IntoUrl) -> Result<Self>
pub fn new(host: impl IntoUrl) -> Result<Self>
Creates a new instance of UnauthenticatedClient with the given host URL.
§Example
let client = UnauthenticatedClient::new("https://pasty.lus.pm").unwrap();
let res = client.application_information().await.unwrap();§Reference
Implementation according to the pasty API documentation: https://github.com/lus/pasty/blob/master/API.md#api
Sourcepub async fn application_information(&self) -> Result<ApplicationInformation>
pub async fn application_information(&self) -> Result<ApplicationInformation>
Returns generall application information of the pasty instance.
§Reference
Binds to the GET /api/v2/info endpoint.
https://github.com/lus/pasty/blob/master/API.md#unsecured-retrieve-application-information
Sourcepub async fn paste(&self, id: &str) -> Result<Paste>
pub async fn paste(&self, id: &str) -> Result<Paste>
Returns a pastes content by it’s ID.
§Reference
Binds to the GET /api/v2/pastes/{paste_id} endpoint.
https://github.com/lus/pasty/blob/master/API.md#unsecured-retrieve-a-paste
Sourcepub async fn create_paste(
&self,
content: impl Into<String>,
metadata: Option<Metadata>,
) -> Result<CreatedPaste>
pub async fn create_paste( &self, content: impl Into<String>, metadata: Option<Metadata>, ) -> Result<CreatedPaste>
Creates a paste with the given content and metadata.
§Reference
Binds to the POST /api/v2/pastes endpoint.
https://github.com/lus/pasty/blob/master/API.md#unsecured-create-a-paste
Sourcepub fn authenticate(self, token: impl Into<String>) -> AuthenticatedClient
pub fn authenticate(self, token: impl Into<String>) -> AuthenticatedClient
Consumes the UnauthenticatedClient and a given paste modification or
admin token to perform authenticated requests.
Trait Implementations§
Source§impl Clone for UnauthenticatedClient
impl Clone for UnauthenticatedClient
Source§fn clone(&self) -> UnauthenticatedClient
fn clone(&self) -> UnauthenticatedClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more