Expand description
Session Serializer module - Batch operations for session file I/O
This module provides high-level functions for batch serialization and deserialization of multiple download sessions. It handles file I/O operations for loading and saving session data.
§Overview
The session serializer is responsible for:
- Loading: Reading session files and deserializing all entries
- Saving: Serializing RequestGroup objects to session file format
- Batch processing: Converting between in-memory representations and file format
§Architecture
This module builds upon SessionEntry from the session_entry module:
- Individual entry parsing/serialization is handled by
SessionEntry - This module handles multi-entry files and RequestGroup conversions
- File I/O operations use atomic write patterns (write tmp + rename)
§File Format
Session files contain one or more entries separated by blank lines:
uri1\turi2
GID=hex_value
option=value
uri3
GID=another_hex
PAUSE=true§Examples
use aria2_core::session::session_serializer::{load_from_file, save_to_file};
use std::path::Path;
#[tokio::main]
async fn main() {
let path = Path::new("aria2.session");
let _entries = load_from_file(path).await.unwrap();
}Re-exports§
pub use super::session_entry::SessionEntry;pub use super::session_entry::decode_hex;pub use super::session_entry::download_options_to_map;pub use super::session_entry::escape_uri;pub use super::session_entry::unescape_uri;
Functions§
- deserialize
- Deserializes session file text into a vector of SessionEntry objects
- group_
to_ entry - Converts a RequestGroup to a SessionEntry for serialization
- load_
from_ file - Loads and deserializes session entries from a file
- save_
to_ file - Saves multiple RequestGroups to a session file using atomic write
- save_
to_ file_ with_ entries - Saves pre-serialized SessionEntry list directly to file (bypasses RequestGroup conversion)
- serialize_
groups - Serializes multiple RequestGroups to session file format