Struct RedmineAsync

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

main API client object (async)

Implementations§

Source§

impl RedmineAsync

Source

pub fn new(redmine_url: Url, api_key: &str) -> Result<Self, Error>

create a RedmineAsync object

§Errors

This will return crate::Error::ReqwestError if initialization of Reqwest client is failed.

Source

pub fn from_env() -> Result<Self, Error>

create a RedmineAsync object from the environment variables

REDMINE_API_KEY REDMINE_URL

§Errors

This will return an error if the environment variables are missing or the URL can not be parsed

Source

pub fn impersonate_user(&mut self, id: u64)

Sets the user id of a user to impersonate in all future API calls

this requires Redmine admin privileges

Source

pub fn issue_url(&self, issue_id: u64) -> Url

returns the issue URL for a given issue id

this is mostly for convenience since we are already storing the redmine URL and it works entirely on the client

Source

pub async fn ignore_response_body<E>(&self, endpoint: &E) -> Result<(), Error>
where E: Endpoint,

use this with endpoints that have no response body, e.g. those just deleting a Redmine object

§Errors

This can return an error if the endpoint returns an error when creating the request body or when the web request fails

Source

pub async fn json_response_body<E, R>(&self, endpoint: &E) -> Result<R, Error>

use this with endpoints which return a JSON response but do not support pagination

you can use it with those that support pagination but they will only return the first page

§Errors

This can return an error if the endpoint returns an error when creating the request body, when the web request fails or when the response can not be parsed as a JSON object into the result type

Source

pub async fn json_response_body_page<E, R>( &self, endpoint: &E, offset: u64, limit: u64, ) -> Result<ResponsePage<R>, Error>

use this to get a single page of a paginated JSON response

§Errors

This can return an error if the endpoint returns an error when creating the request body, when the web request fails, when the response can not be parsed as a JSON object, when any of the pagination keys or the value key are missing in the JSON object or when the values can not be parsed as the result type.

Source

pub async fn json_response_body_all_pages<E, R>( &self, endpoint: &E, ) -> Result<Vec<R>, Error>

use this to get the results for all pages of a paginated JSON response

§Errors

This can return an error if the endpoint returns an error when creating the request body, when any of the web requests fails, when the response can not be parsed as a JSON object, when any of the pagination keys or the value key are missing in the JSON object or when the values can not be parsed as the result type.

Trait Implementations§

Source§

impl Debug for RedmineAsync

Source§

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

Formats the value using the given formatter. Read more

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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

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

Source§

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>,

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

impl<T> ErasedDestructor for T
where T: 'static,