Expand description
Session Entry module - Core data structure for session serialization
This module provides the SessionEntry struct which represents a single download
task’s state that can be serialized to and deserialized from session files.
§Overview
A SessionEntry captures all necessary information about an active or paused download:
- URIs: One or more source URLs (mirrors) for the download
- GID: Unique identifier for the download task
- Options: Download configuration options (split, dir, out, etc.)
- Progress: Current download/upload statistics
- Status: Active state of the download (active, waiting, paused, error)
- BT-specific: Bitfield and piece information for BitTorrent downloads
§Architecture
session_entry.rs (this file)
├── SessionEntry struct definition
├── Builder pattern methods (new, with_options, paused)
└── Re-exports for convenience
session_serialize_impl.rs
└── impl SessionEntry { serialize(), deserialize_line() }
session_uri_utils.rs
└── escape_uri(), unescape_uri(), decode_hex()
session_options.rs
└── download_options_to_map()§Examples
use aria2_core::session::session_entry::SessionEntry;
use std::collections::HashMap;
// Create a basic entry
let entry = SessionEntry::new(1, vec!["http://example.com/file.zip".to_string()]);
// Add options using builder pattern
let entry = SessionEntry::new(2, vec!["http://example.com/big.iso".to_string()])
.with_options({
let mut opts = HashMap::new();
opts.insert("split".to_string(), "4".to_string());
opts.insert("dir".to_string(), "/downloads".to_string());
opts
})
.paused();Structs§
- Session
Entry - Represents a single download task in a session file
Functions§
- decode_
hex - Decodes a hexadecimal string to a byte vector.
- download_
options_ to_ map - Converts DownloadOptions struct to a HashMap for serialization.
- escape_
uri - Escapes special characters in URIs for safe serialization.
- unescape_
uri - Unescapes special characters previously escaped by
escape_uri().