spark-channel 0.0.1

A generic channel listener for Spark
Documentation
//! # Spark Channel Cancellation Token
//!
//! This module contains a cancellation token that wraps the [`CancellationToken`] type from the [`tokio-util`] crate. This is used to cancel the execution of a running task.

use tokio_util::sync::CancellationToken;

use crate::listener::SparkChannelCancellationTrait;

/// A cancellation token for the Spark Channel.
#[derive(Clone)]
pub struct SparkChannelCancellationToken(pub CancellationToken);

impl SparkChannelCancellationToken {
    /// Creates a new cancellation token.
    #[must_use]
    #[inline]
    pub fn new() -> Self {
        Self(CancellationToken::new())
    }
}

impl SparkChannelCancellationTrait for SparkChannelCancellationToken {
    fn cancel_execution(&self) {
        self.0.cancel();
    }
}