Skip to main content

deserialize

Function deserialize 

Source
pub fn deserialize(text: &str) -> Result<Vec<SessionEntry>>
Expand description

Deserializes session file text into a vector of SessionEntry objects

Parses the entire contents of a session file and returns all valid entries found. Handles comments (#) and blank lines.

§Arguments

  • text - Full contents of a session file as a string

§Returns

Result containing a Vec of successfully parsed SessionEntry objects

§Format Details

Each entry consists of:

  1. A URI line (one or more tab-separated URIs)
  2. Zero or more property lines (space-prefixed key=value pairs)
  3. Separated from next entry by blank line

§Error Handling

  • Empty lines and comments are silently skipped
  • Invalid values are ignored (with warnings logged)
  • Malformed hex strings cause bitfield to be ignored

§Example

use aria2_core::session::session_serializer::deserialize;

let input = r#"http://example.com/file.zip
 GID=1
 split=4

ftp://server/big.iso
 GID=2
 PAUSE=true
"#;

let entries = deserialize(input).unwrap();
assert_eq!(entries.len(), 2);
assert!(!entries[0].paused);
assert!(entries[1].paused);