Skip to main content

shaul_core/
lib.rs

1//! Core domain and engine for shaul.
2//!
3//! The main chain is:
4//! `Link -> LinkParser -> Resource -> Router -> DownloadBackend`, driven by
5//! [`DownloadEngine`] over [`Task`] / [`FileItem`] / segments.
6
7#![forbid(unsafe_code)]
8#![warn(missing_docs)]
9
10/// Archive detection and safe extraction.
11pub mod archive;
12/// Download backend trait plus the request/outcome types exchanged with it.
13pub mod backend;
14/// Blocking facade over the asynchronous engine.
15pub mod blocking;
16/// Content-addressed cache for verified downloads.
17pub mod cache;
18/// Checksum algorithms, checksum parsing and file digest computation.
19pub mod checksum;
20/// Configuration files, sections and resolved download options.
21pub mod config;
22/// Destination filesystem checks.
23pub mod disk;
24/// Asynchronous engine that drives tasks through parsers, backends and
25/// finalizers.
26pub mod engine;
27/// Central error type and result alias.
28pub mod error;
29/// Progress event types and event sinks.
30pub mod event;
31/// Post-download verification and extraction pipeline.
32pub mod finalizer;
33/// Validated HTTP headers, authentication and request options.
34pub mod header;
35/// Raw user input and its validation.
36pub mod link;
37/// Link parser trait, registry and parse options.
38pub mod parser;
39/// File-name sanitization and safe path joining.
40pub mod path;
41/// Byte-range arithmetic used for segmentation and resume.
42pub mod range;
43/// Backend-agnostic descriptions of the resource to download.
44pub mod resource;
45/// Routing of links to parsers and resources to backends.
46pub mod router;
47/// Task persistence traits and the JSON sidecar store.
48pub mod store;
49/// Task, file and resume state bookkeeping.
50pub mod task;
51/// Numeric metrics hooks for external monitoring systems.
52pub mod telemetry;
53mod util;
54
55pub use archive::{
56    ArchiveExtractor, BuiltinExtractor, ExtractReport, ExtractorRegistry, ExtractorRequest,
57};
58pub use backend::{
59    BackendCapabilities, DownloadBackend, DownloadOutcome, DownloadRequest, FileOutcome,
60    ResumeCheckpoint,
61};
62pub use blocking::BlockingEngine;
63pub use cache::{CachePruneReport, CacheStats, ContentCache};
64pub use checksum::{Checksum, ChecksumAlgorithm, compute_file_checksum};
65pub use config::{BtConfig, Config, DownloadConfig, HubConfig, NetworkConfig, ResolvedOptions};
66pub use disk::ensure_free_space;
67pub use engine::DownloadEngine;
68pub use error::{Error, Result};
69pub use event::{DownloadEvent, EventKind, EventSink};
70pub use finalizer::{
71    ExtractFinalizer, ExtractorFinalizer, FinalizeContext, FinalizeResult, Finalizer,
72    FinalizerPipeline, VerifyFinalizer,
73};
74pub use header::{Auth, Header, RequestOptions, expand_env};
75pub use link::Link;
76pub use parser::{LinkParser, ParseOptions, ParserRegistry};
77pub use path::{safe_join, sanitize_file_name, sanitize_relative_path};
78pub use range::{ByteRange, completed_bytes, merge_ranges, missing_ranges, split_range};
79pub use resource::{
80    BitTorrentSource, HubProvider, HubRepoType, Resource, ResourceFile, ResourceKind,
81};
82pub use router::{RoutedResource, Router, backend_arc, parser_arc};
83pub use store::{SidecarStore, TaskStore, TaskUpdate};
84pub use task::{
85    FileItem, FileResume, FileState, Task, TaskId, TaskOptions, TaskResume, TaskState, Validator,
86    VerifyMode, destination_file, part_path,
87};
88pub use telemetry::{NoopTelemetry, Telemetry, metrics};
89pub use tokio_util::sync::CancellationToken;