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: SyncCommandTypeThe type of command (e.g., ItemAdd, ProjectUpdate).
uuid: StringUnique identifier for this command (for idempotency).
temp_id: Option<String>Temporary ID for newly created resources.
args: ValueCommand-specific arguments.
Implementations§
Source§impl SyncCommand
impl SyncCommand
Sourcepub fn new(command_type: SyncCommandType, args: Value) -> Self
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);Sourcepub fn with_temp_id(
command_type: SyncCommandType,
temp_id: impl Into<String>,
args: Value,
) -> Self
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()));Sourcepub fn with_uuid_and_temp_id(
command_type: SyncCommandType,
uuid: impl Into<String>,
temp_id: impl Into<String>,
args: Value,
) -> Self
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.
Sourcepub fn item_close(id: impl Into<String>) -> Self
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");Sourcepub fn item_uncomplete(id: impl Into<String>) -> Self
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");Sourcepub fn item_delete(id: impl Into<String>) -> Self
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");Sourcepub fn project_delete(id: impl Into<String>) -> Self
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");Sourcepub fn project_archive(id: impl Into<String>) -> Self
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");Sourcepub fn project_unarchive(id: impl Into<String>) -> Self
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");Sourcepub fn section_delete(id: impl Into<String>) -> Self
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");Sourcepub fn section_archive(id: impl Into<String>) -> Self
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");Sourcepub fn section_unarchive(id: impl Into<String>) -> Self
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");Sourcepub fn label_delete(id: impl Into<String>) -> Self
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");Sourcepub fn note_delete(id: impl Into<String>) -> Self
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");Sourcepub fn project_note_delete(id: impl Into<String>) -> Self
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");Sourcepub fn reminder_delete(id: impl Into<String>) -> Self
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");Sourcepub fn filter_delete(id: impl Into<String>) -> Self
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
impl Clone for SyncCommand
Source§fn clone(&self) -> SyncCommand
fn clone(&self) -> SyncCommand
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more