pub struct TaskOutcome {
pub task_id: TaskId,
pub payload: Option<String>,
}Expand description
Main entry point of the rusty-cat SDK.
MeowClient owns runtime state and provides high-level operations:
enqueue, pause, resume, cancel, snapshot, and close.
§Usage pattern
- Create
MeowConfig. - Construct
MeowClient::new(config). - Build tasks with upload/download builders.
- Call [
Self::enqueue] and store returnedTaskId. - Control task lifecycle with pause/resume/cancel.
- Call [
Self::close] during shutdown.
§Lifecycle contract: you must call [Self::close]
The background scheduler runs on a dedicated std::thread that drives
its own Tokio runtime. The clean shutdown protocol is an explicit
close().await command which:
- cancels in-flight transfers,
- flushes
Pausedstatus events to user callbacks for every known group, - drains already submitted callback jobs,
- joins the scheduler thread and lets the runtime drop.
Forgetting to call close leaves the scheduler thread alive until all
command senders are dropped (which does happen when MeowClient is
dropped, but only as a fallback). When that fallback path runs, the
guarantees above do not hold: callers may miss terminal status
events, in-flight HTTP transfers are aborted abruptly, and for long-lived
SDK hosts (servers, mobile runtimes, etc.) the misuse is nearly
impossible to debug from the outside.
To help surface this misuse the internal executor implements a
best-effort Drop that, when close was never called:
- emits a
Warn-level log via the debug log listener (tag"executor_drop"), - performs a non-blocking
try_sendof a finalClosecommand so the worker still has a chance to drain its state, - then drops the command sender, causing the worker loop to exit on its own.
This is a safety net, not a substitute for calling close. Treat
close().await as a mandatory step in your shutdown sequence.
§Sharing across tasks / threads
MeowClient intentionally does not implement Clone.
The client owns a lazily-initialized [Executor] (a single background
worker loop plus its task table, scheduler state and shutdown flag). A
naive field-by-field Clone would copy the OnceLock<Executor> before
it was initialized, letting different clones each spin up their own
executor on first use. The result would be:
- multiple independent task tables (tasks enqueued via one clone are
invisible to
pause/resume/cancel/snapshoton another); - concurrency limits (
MeowConfig::max_upload_concurrency/MeowConfig::max_download_concurrency) silently multiplied by the number of clones; - [
Self::close] only shutting down one of the worker loops, leaking the rest.
To share a client across tasks or threads, wrap it in std::sync::Arc
and clone the Arc instead:
use std::sync::Arc;
use rusty_cat::api::{MeowClient, MeowConfig};
let client = Arc::new(MeowClient::new(MeowConfig::default()));
let client_for_task = Arc::clone(&client);
tokio::spawn(async move {
let _ = client_for_task; // use the shared client here
});Outcome of a task that reached TransferStatus::Complete.
Returned by MeowClient::enqueue_and_wait.
Fields§
§task_id: TaskIdTask identifier returned by the underlying scheduler.
payload: Option<String>Provider-defined payload returned by upload protocol’s complete_upload.
Download tasks usually receive None.
Trait Implementations§
Source§impl Clone for TaskOutcome
impl Clone for TaskOutcome
Source§fn clone(&self) -> TaskOutcome
fn clone(&self) -> TaskOutcome
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more