1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//! # megalib
//!
//! Rust client library for Mega.nz cloud storage.
//!
//! ## Features
//!
//! - **Authentication**: Login with email/password, support for HTTP proxies, and specific session handling.
//! - Full account registration flow (register + verify).
//! - **Filesystem Operations**:
//! - List files and folders (support for recursive listing).
//! - Create directories (`mkdir`).
//! - Move (`mv`), rename, and delete (`rm`) files/folders.
//! - Get file attributes (`stat`) and user quota information.
//! - **File Transfers**:
//! - Robust upload and download with automatic resume support.
//! - Parallel transfer workers for improved performance.
//! - Progress tracking with custom callbacks.
//! - Optional preview generation for media uploads.
//! - **Sharing & Public Access**:
//! - Export public download links (`export`).
//! - Parse and download files from public MEGA links.
//! - Open and browse public folders (`open_folder`) without login.
//!
//! ## Example: Basic Usage
//!
//! ```no_run
//! use megalib::Session;
//!
//! # async fn example() -> megalib::Result<()> {
//! // Login
//! let mut session = Session::login("user@example.com", "password").await?;
//!
//! // List files in root
//! let files = session.list("/", false)?;
//! for file in files {
//! println!("{} ({} bytes)", file.name, file.size);
//! }
//!
//! // Upload a file with resume support
//! session.upload_resumable("local_file.txt", "/Root").await?;
//!
//! // Download a file to local disk
//! if let Some(node) = session.stat("/Root/remote_file.txt").cloned() {
//! session.download_to_file(&node, "downloaded_file.txt").await?;
//! }
//!
//! # Ok(())
//! # }
//! ```
//!
//! ## Example: Account Registration
//!
//! Registration is a two-step process:
//!
//! ```no_run
//! use megalib::session::{register, verify_registration};
//!
//! # async fn example() -> megalib::Result<()> {
//! // Step 1: Initiate registration (sends verification email)
//! let state = register("user@example.com", "SecurePassword123", "John Doe", None).await?;
//! println!("Check your email! State to save: {}", state.serialize());
//!
//! // Step 2: After receiving email, complete registration
//! // let signup_key = "..."; // Extract from email link
//! // verify_registration(&state, signup_key).await?;
//! # Ok(())
//! # }
//! ```
// Re-export commonly used types
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;