Skip to main content

TasksClient

Struct TasksClient 

Source
pub struct TasksClient<'a, T = Uninitialized> { /* private fields */ }

Implementations§

Source§

impl<'a> TasksClient<'a, Uninitialized>

Source

pub fn new(client: &'a mut GoogleClient) -> Self

Source

pub fn get_task_lists(self) -> TasksClient<'a, TaskListMode>

Get a list of tasklists from the specified user.

§Examples

Axum is used in this example, but it can be adapted to other frameworks like Actix or Rocket.

 pub async fn get_tasks(State(state): State<AppState>,
 Path((task_list_id): Path<(String, String) -> Json<TaskLists> {
     let google_client_guard = state.google_client.lock().await;
     let client = google_client_guard.as_ref().unwrap();
     let res = TasksClient::new(client)
         .get_tasks(&task_list_id)
         .max_results(10)
         .page_token(1)
         .show_deleted(false)
         .request()
         .await.unwrap();

     Json(res.unwrap_or_default())
 }
Source

pub fn get_tasks(self, task_list_id: &str) -> TasksClient<'a, TasksMode>

Get a list of tasks from the specified task list.

§Examples

Axum is used in this example, but it can be adapted to other frameworks like Actix or Rocket.

 pub async fn get_tasks(State(state): State<AppState>,
 Path((task_list_id): Path<(String, String) -> Json<Tasks> {
     let google_client_guard = state.google_client.lock().await;
     let client = google_client_guard.as_ref().unwrap();
     let res = TasksClient::new(client)
         .get_tasks(&task_list_id)
         .max_results(10)
         .page_token(1)
         .show_deleted(false)
         .request()
         .await.unwrap();

     Json(res.unwrap_or_default())
 }
Source

pub fn insert_task(self, task_list_id: &str) -> TasksClient<'a, TaskInsertMode>

Insert a task from the specified task list.

§Examples

Axum is used in this example, but it can be adapted to other frameworks like Actix or Rocket.

 pub async fn get_tasks(State(state): State<AppState>,
 Path((task_id, task_list_id): Path<(String, String) {
     let google_client_guard = state.google_client.lock().await;
     let client = google_client_guard.as_ref().unwrap();
     let res = TasksClient::new(client)
         .insert_task(&task_list_id)
         .set_task_notes("This is a new task")
         .set_task_title("New Task")
         .request()
         .await.unwrap();
 }
Source

pub fn complete_task( self, task_id: &str, task_list_id: &str, ) -> TasksClient<'a, TaskPatchMode>

Complete a task from the specified task list.

§Examples

Axum is used in this example, but it can be adapted to other frameworks like Actix or Rocket.

 pub async fn get_tasks(State(state): State<AppState>,
 Path((task_id, task_list_id): Path<(String, String) {
     let google_client_guard = state.google_client.lock().await;
     let client = google_client_guard.as_ref().unwrap();
     let res = TasksClient::new(client)
         .complete_task(&task_list_id, &task_id)
         .request()
         .await.unwrap();
 }
Source

pub fn delete_task( self, task_id: &str, task_list_id: &str, ) -> TasksClient<'a, TaskDeleteMode>

Delete a task from the specified task list.

§Examples

Axum is used in this example, but it can be adapted to other frameworks like Actix or Rocket.

 pub async fn get_tasks(State(state): State<AppState>,
 Path((task_id, task_list_id): Path<(String, String) {
     let google_client_guard = state.google_client.lock().await;
     let client = google_client_guard.as_ref().unwrap();
     let res = TasksClient::new(client)
         .delete_task(&task_list_id, &task_id)
         .request()
         .await.unwrap();
 }
Source§

impl<'a> TasksClient<'a, TaskListMode>

Source

pub async fn request(&mut self) -> Result<Option<TaskLists>, Error>

Makes a request to retrieve the task lists.

Source§

impl<'a> TasksClient<'a, TasksMode>

A client for interacting with the Google Tasks API in retrieval mode.

This client allows querying task lists with various filtering options such as completion status, due dates, and visibility settings.

§Example

let client = TasksClient::new(client);
let tasks = client.show_completed(true).get_due_min(some_date).request().await?;
Source

pub async fn request(&mut self) -> Result<Option<Tasks>, Error>

Makes a request to retrieve the tasks from the specified task list.

§Returns
  • Result<Option<Tasks>, Error> - A result containing the tasks if successful, or an error if the request failed. Returns None if no tasks were found.
Source

pub fn get_completed_max(self, completed_max: DateTime<Utc>) -> Self

Filter tasks by completion date to include only tasks completed before the specified date.

§Arguments
  • completed_max - The upper bound (exclusive) for a task’s completion date to filter by
§Returns
  • Self - Returns the client for method chaining
Source

pub fn get_completed_min(self, completed_min: DateTime<Utc>) -> Self

Filter tasks by completion date to include only tasks completed after the specified date.

§Arguments
  • completed_min - The lower bound (inclusive) for a task’s completion date to filter by
§Returns
  • Self - Returns the client for method chaining
Source

pub fn get_due_max(self, due_max: DateTime<Utc>) -> Self

Filter tasks by due date to include only tasks due before the specified date.

§Arguments
  • due_max - The upper bound (exclusive) for a task’s due date to filter by
§Returns
  • Self - Returns the client for method chaining
Source

pub fn get_due_min(self, due_min: DateTime<Utc>) -> Self

Filter tasks by due date to include only tasks due after the specified date.

§Arguments
  • due_min - The lower bound (inclusive) for a task’s due date to filter by
§Returns
  • Self - Returns the client for method chaining
Source

pub fn show_completed(self, show_completed: bool) -> Self

Control whether completed tasks are included in the result.

§Arguments
  • show_completed - If true, completed tasks are included in the result
§Returns
  • Self - Returns the client for method chaining
Source

pub fn show_deleted(self, show_due: bool) -> Self

Control whether deleted tasks are included in the result.

§Arguments
  • show_deleted - If true, deleted tasks are included in the result
§Returns
  • Self - Returns the client for method chaining
Source

pub fn show_hidden(self, show_hidden: bool) -> Self

Control whether hidden tasks are included in the result.

§Arguments
  • show_hidden - If true, hidden tasks are included in the result
§Returns
  • Self - Returns the client for method chaining
Source

pub fn get_updated_min(self, updated_min: DateTime<Utc>) -> Self

Filter tasks to include only those updated after the specified time.

§Arguments
  • updated_min - The minimum last updated date (inclusive) to filter by
§Returns
  • Self - Returns the client for method chaining
Source

pub fn show_assigned(self, show_assigned: bool) -> Self

Control whether assigned tasks are included in the result.

§Arguments
  • show_assigned - If true, assigned tasks are included in the result
§Returns
  • Self - Returns the client for method chaining
Source§

impl<'a> TasksClient<'a, TaskInsertMode>

A client for interacting with the Google Tasks API in task insertion mode.

This client allows creating new tasks with various properties such as title, notes, due dates, and hierarchical placement.

§Example

let client = TasksClient::new(client);
let task = client.set_task_title("New Task").set_task_notes("Details").request().await?;
Source

pub async fn request(&mut self) -> Result<Option<Tasks>, Error>

Makes a request to create a task with the specified properties.

§Returns
  • Result<Option<Tasks>, Error> - A result containing the created task if successful, or an error if the request failed.
Source

pub fn set_parent(self, parent_id: &str) -> Self

Sets the parent task for this task, establishing a hierarchical relationship.

§Arguments
  • parent_id - The ID of the parent task
§Returns
  • Self - Returns the client for method chaining
Source

pub fn set_previous(self, previous_id: &str) -> Self

Sets the previous sibling task for this task, establishing the order of tasks.

§Arguments
  • previous_id - The ID of the previous task in the sequence
§Returns
  • Self - Returns the client for method chaining
Source

pub fn set_task(self, task: Task) -> Self

Sets the complete task object to be inserted.

§Arguments
  • task - The Task object containing all properties to be set
§Returns
  • Self - Returns the client for method chaining
Source

pub fn set_task_title(self, title: &str) -> Self

Sets the title of the task to be created.

§Arguments
  • title - The title for the task
§Returns
  • Self - Returns the client for method chaining
Source

pub fn set_task_etag(self, etag: &str) -> Self

Sets the ETag of the task to be created.

§Arguments
  • etag - The ETag for the task
§Returns
  • Self - Returns the client for method chaining
Source

pub fn set_task_notes(self, notes: &str) -> Self

Sets the notes describing the task.

§Arguments
  • notes - The notes for the task (max 8192 characters)
§Returns
  • Self - Returns the client for method chaining
Source

pub fn set_task_due(self, due: DateTime<Utc>) -> Self

Sets the due date of the task.

§Arguments
  • due - The due date for the task (as a DateTime)
§Returns
  • Self - Returns the client for method chaining
Source

pub fn set_task_completed(self, completed: DateTime<Utc>) -> Self

Sets the completion date of the task.

§Arguments
  • completed - The datetime when the task was completed
§Returns
  • Self - Returns the client for method chaining
Source

pub fn set_task_hidden(self, hidden: bool) -> Self

Sets the hidden status of the task.

§Arguments
  • hidden - If true, marks the task as hidden
§Returns
  • Self - Returns the client for method chaining

Sets the links associated with the task.

§Arguments
  • links - A vector of TaskLink objects to associate with the task
§Returns
  • Self - Returns the client for method chaining
Source§

impl<'a> TasksClient<'a, TaskPatchMode>

Source

pub async fn request(&mut self) -> Result<Option<Task>, Error>

Makes a request to update the task with the specified properties.

§Returns
  • Result<Option<Tasks>, Error> - A result containing the updated task if successful, or an error if the request failed.
Source§

impl<'a> TasksClient<'a, TaskDeleteMode>

Source

pub async fn request(&mut self) -> Result<bool, Error>

Makes a request to delete the specified task.

§Returns
  • Result<bool, Error> - A result indicating whether the deletion was successful.

Trait Implementations§

Source§

impl<'a, T: InitializedGetMode> PaginationRequestTrait for TasksClient<'a, T>

Source§

fn max_results(self, max: i64) -> Self

Sets the maximum number of results to return.

Source§

fn page_token(self, token: &str) -> Self

Sets the page token for pagination. Works with max_results.

Auto Trait Implementations§

§

impl<'a, T = Uninitialized> !RefUnwindSafe for TasksClient<'a, T>

§

impl<'a, T = Uninitialized> !UnwindSafe for TasksClient<'a, T>

§

impl<'a, T> Freeze for TasksClient<'a, T>
where PhantomData<T>: Freeze,

§

impl<'a, T> Send for TasksClient<'a, T>
where PhantomData<T>: Send,

§

impl<'a, T> Sync for TasksClient<'a, T>
where PhantomData<T>: Sync,

§

impl<'a, T> Unpin for TasksClient<'a, T>
where PhantomData<T>: Unpin,

§

impl<'a, T> UnsafeUnpin for TasksClient<'a, T>

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> ErasedDestructor for T
where T: 'static,

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: Sized + 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: Sized + 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 = !

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