Skip to main content

SyncCommand

Struct SyncCommand 

Source
pub struct SyncCommand {
    pub command_type: SyncCommandType,
    pub uuid: String,
    pub temp_id: Option<String>,
    pub args: Value,
}
Expand description

A command to execute via the Sync API.

Commands are write operations that modify resources in Todoist. Each command has a UUID for idempotency and optional temp_id for creating resources that can be referenced by other commands.

§Examples

§Create a simple command using type-safe builder

use todoist_api_rs::sync::{SyncCommand, SyncCommandType};
use serde_json::json;

let cmd = SyncCommand::new(SyncCommandType::ItemClose, json!({"id": "task-123"}));
assert_eq!(cmd.command_type, SyncCommandType::ItemClose);
assert!(cmd.temp_id.is_none());

§Use convenience builders for common operations

use todoist_api_rs::sync::SyncCommand;

let cmd = SyncCommand::item_close("task-123");
assert!(cmd.args["id"].as_str() == Some("task-123"));

§Create a command with temp_id for new resources

use todoist_api_rs::sync::{SyncCommand, SyncCommandType};
use serde_json::json;

// When creating a new item, use temp_id so you can reference it in subsequent commands
let cmd = SyncCommand::with_temp_id(
    SyncCommandType::ItemAdd,
    "temp-task-1",
    json!({"content": "Buy groceries", "project_id": "inbox"})
);
assert_eq!(cmd.temp_id, Some("temp-task-1".to_string()));

Fields§

§command_type: SyncCommandType

The type of command (e.g., ItemAdd, ProjectUpdate).

§uuid: String

Unique identifier for this command (for idempotency).

§temp_id: Option<String>

Temporary ID for newly created resources.

§args: Value

Command-specific arguments.

Implementations§

Source§

impl SyncCommand

Source

pub fn new(command_type: SyncCommandType, args: Value) -> Self

Creates a new command with a generated UUID.

§Examples
use todoist_api_rs::sync::{SyncCommand, SyncCommandType};
use serde_json::json;

let cmd = SyncCommand::new(SyncCommandType::ItemClose, json!({"id": "task-123"}));
assert_eq!(cmd.command_type, SyncCommandType::ItemClose);
Source

pub fn with_temp_id( command_type: SyncCommandType, temp_id: impl Into<String>, args: Value, ) -> Self

Creates a new command with a temp_id for resource creation.

Use this when creating new resources that need to be referenced by subsequent commands in the same batch.

§Examples
use todoist_api_rs::sync::{SyncCommand, SyncCommandType};
use serde_json::json;

let cmd = SyncCommand::with_temp_id(
    SyncCommandType::ItemAdd,
    "temp-123",
    json!({"content": "Buy groceries"})
);
assert_eq!(cmd.temp_id, Some("temp-123".to_string()));
Source

pub fn with_uuid_and_temp_id( command_type: SyncCommandType, uuid: impl Into<String>, temp_id: impl Into<String>, args: Value, ) -> Self

Creates a new command with explicit UUID and temp_id.

Use this when you need deterministic UUIDs for testing or idempotency.

Source

pub fn item_close(id: impl Into<String>) -> Self

Creates an item_close command to complete a task.

§Examples
use todoist_api_rs::sync::SyncCommand;

let cmd = SyncCommand::item_close("task-123");
assert_eq!(cmd.args["id"], "task-123");
Source

pub fn item_uncomplete(id: impl Into<String>) -> Self

Creates an item_uncomplete command to reopen a task.

§Examples
use todoist_api_rs::sync::SyncCommand;

let cmd = SyncCommand::item_uncomplete("task-123");
assert_eq!(cmd.args["id"], "task-123");
Source

pub fn item_delete(id: impl Into<String>) -> Self

Creates an item_delete command to delete a task.

§Examples
use todoist_api_rs::sync::SyncCommand;

let cmd = SyncCommand::item_delete("task-123");
assert_eq!(cmd.args["id"], "task-123");
Source

pub fn project_delete(id: impl Into<String>) -> Self

Creates a project_delete command to delete a project.

§Examples
use todoist_api_rs::sync::SyncCommand;

let cmd = SyncCommand::project_delete("proj-123");
assert_eq!(cmd.args["id"], "proj-123");
Source

pub fn project_archive(id: impl Into<String>) -> Self

Creates a project_archive command to archive a project.

§Examples
use todoist_api_rs::sync::SyncCommand;

let cmd = SyncCommand::project_archive("proj-123");
assert_eq!(cmd.args["id"], "proj-123");
Source

pub fn project_unarchive(id: impl Into<String>) -> Self

Creates a project_unarchive command to unarchive a project.

§Examples
use todoist_api_rs::sync::SyncCommand;

let cmd = SyncCommand::project_unarchive("proj-123");
assert_eq!(cmd.args["id"], "proj-123");
Source

pub fn section_delete(id: impl Into<String>) -> Self

Creates a section_delete command to delete a section.

§Examples
use todoist_api_rs::sync::SyncCommand;

let cmd = SyncCommand::section_delete("section-123");
assert_eq!(cmd.args["id"], "section-123");
Source

pub fn section_archive(id: impl Into<String>) -> Self

Creates a section_archive command to archive a section.

§Examples
use todoist_api_rs::sync::SyncCommand;

let cmd = SyncCommand::section_archive("section-123");
assert_eq!(cmd.args["id"], "section-123");
Source

pub fn section_unarchive(id: impl Into<String>) -> Self

Creates a section_unarchive command to unarchive a section.

§Examples
use todoist_api_rs::sync::SyncCommand;

let cmd = SyncCommand::section_unarchive("section-123");
assert_eq!(cmd.args["id"], "section-123");
Source

pub fn label_delete(id: impl Into<String>) -> Self

Creates a label_delete command to delete a label.

§Examples
use todoist_api_rs::sync::SyncCommand;

let cmd = SyncCommand::label_delete("label-123");
assert_eq!(cmd.args["id"], "label-123");
Source

pub fn note_delete(id: impl Into<String>) -> Self

Creates a note_delete command to delete a task comment.

§Examples
use todoist_api_rs::sync::SyncCommand;

let cmd = SyncCommand::note_delete("note-123");
assert_eq!(cmd.args["id"], "note-123");
Source

pub fn project_note_delete(id: impl Into<String>) -> Self

Creates a project_note_delete command to delete a project comment.

§Examples
use todoist_api_rs::sync::SyncCommand;

let cmd = SyncCommand::project_note_delete("note-123");
assert_eq!(cmd.args["id"], "note-123");
Source

pub fn reminder_delete(id: impl Into<String>) -> Self

Creates a reminder_delete command to delete a reminder.

§Examples
use todoist_api_rs::sync::SyncCommand;

let cmd = SyncCommand::reminder_delete("reminder-123");
assert_eq!(cmd.args["id"], "reminder-123");
Source

pub fn filter_delete(id: impl Into<String>) -> Self

Creates a filter_delete command to delete a filter.

§Examples
use todoist_api_rs::sync::SyncCommand;

let cmd = SyncCommand::filter_delete("filter-123");
assert_eq!(cmd.args["id"], "filter-123");

Trait Implementations§

Source§

impl Clone for SyncCommand

Source§

fn clone(&self) -> SyncCommand

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SyncCommand

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for SyncCommand

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for SyncCommand

Source§

fn eq(&self, other: &SyncCommand) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for SyncCommand

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for SyncCommand

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,