pub struct BlockingEngine { /* private fields */ }Expand description
Synchronous facade for callers that do not want to own a Tokio runtime. The async engine remains the single implementation.
Implementations§
Source§impl BlockingEngine
impl BlockingEngine
Sourcepub fn new(
router: Router,
store: Arc<dyn TaskStore>,
config: Config,
) -> Result<Self>
pub fn new( router: Router, store: Arc<dyn TaskStore>, config: Config, ) -> Result<Self>
Creates an engine backed by a dedicated multi-threaded Tokio runtime.
Sourcepub fn engine(&self) -> &DownloadEngine
pub fn engine(&self) -> &DownloadEngine
Returns a reference to the underlying asynchronous engine.
Sourcepub fn subscribe(&self) -> Receiver<DownloadEvent>
pub fn subscribe(&self) -> Receiver<DownloadEvent>
Subscribes to engine events, delivered over a standard library channel.
Sourcepub fn download(
&self,
link: Link,
destination: PathBuf,
options: TaskOptions,
) -> Result<Task>
pub fn download( &self, link: Link, destination: PathBuf, options: TaskOptions, ) -> Result<Task>
Adds a task and runs it to completion, blocking the current thread.
Sourcepub fn add(
&self,
link: Link,
destination: PathBuf,
options: TaskOptions,
) -> Result<Task>
pub fn add( &self, link: Link, destination: PathBuf, options: TaskOptions, ) -> Result<Task>
Registers a task without running it.
Sourcepub fn run_task(&self, id: TaskId) -> Result<Task>
pub fn run_task(&self, id: TaskId) -> Result<Task>
Blocks until the given task finishes and returns its final state.
Sourcepub fn pause(&self, id: TaskId) -> Result<Task>
pub fn pause(&self, id: TaskId) -> Result<Task>
Marks a task paused and cancels its in-flight transfer.
Sourcepub fn run_pending(
&self,
jobs: usize,
cancel: CancellationToken,
) -> Result<Vec<Task>>
pub fn run_pending( &self, jobs: usize, cancel: CancellationToken, ) -> Result<Vec<Task>>
Runs every pending task, at most jobs at a time.
Sourcepub fn requeue_stale(&self) -> Result<Vec<TaskId>>
pub fn requeue_stale(&self) -> Result<Vec<TaskId>>
Requeues tasks left in Running by a previous process.
Auto Trait Implementations§
impl !Freeze for BlockingEngine
impl !RefUnwindSafe for BlockingEngine
impl !UnwindSafe for BlockingEngine
impl Forget for BlockingEngine
impl Move for BlockingEngine
impl Send for BlockingEngine
impl Sync for BlockingEngine
impl Unpin for BlockingEngine
impl UnsafeUnpin for BlockingEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more