Skip to main content

TaskOutcome

Struct TaskOutcome 

Source
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

  1. Create MeowConfig.
  2. Construct MeowClient::new(config).
  3. Build tasks with upload/download builders.
  4. Call [Self::enqueue] and store returned TaskId.
  5. Control task lifecycle with pause/resume/cancel.
  6. 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 Paused status 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_send of a final Close command 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:

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: TaskId

Task 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

Source§

fn clone(&self) -> TaskOutcome

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TaskOutcome

Source§

fn fmt(&self, 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> 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