tidepool-version-manager

Crates.iotidepool-version-manager
lib.rstidepool-version-manager
version0.1.5
created_at2025-06-28 09:49:13.309365+00
updated_at2025-07-13 08:51:28.912962+00
descriptionVersion management for Tidepool toolkit
homepage
repositoryhttps://github.com/Slothtron/tidepool
max_upload_size
id1729693
size222,176
Slothtron (Slothtron)

documentation

README

Tidepool Version Manager

πŸ“– Language: English | δΈ­ζ–‡

Crates.io Documentation License Rust

tidepool-version-manager is the core library of the Tidepool project, providing powerful runtime version management capabilities. It supports installation, switching, uninstallation, and management of multiple programming language runtimes. Currently focused on Go version management, it will expand to support Python, Node.js, and more runtimes in the future.

🌟 Features

πŸš€ Core Functionality

  • Async Version Installation - High-performance concurrent downloading and installation
  • Smart Version Switching - Cross-platform version switching mechanism
  • Complete Lifecycle Management - Install, switch, uninstall, and list operations
  • Status Querying - Real-time runtime status checking
  • Multi-Platform Support - Full compatibility with Windows, macOS, and Linux

πŸ”§ Downloader Features

  • Chunked Concurrent Downloads - Multi-connection download acceleration
  • Resume Downloads - Automatic recovery from network interruptions
  • Progress Reporting - Real-time download progress feedback
  • File Integrity Verification - SHA256 checksums for security
  • Smart Retry Mechanism - Automatic handling of network exceptions

πŸ›‘οΈ Security Features

  • File Hash Verification - Automatic verification of downloaded file integrity
  • Permission Security - Cross-platform symlinks without administrator privileges
  • Safe Uninstallation - Protection mechanisms to prevent accidental system file deletion

πŸ“¦ Installation

Add the following to your Cargo.toml:

[dependencies]

[dependencies]
tidepool-version-manager = "0.1.5"

## πŸš€ Quick Start

### Basic Usage

```rust
use tidepool_version_manager::{
    go::GoManager,
    VersionManager,
    InstallRequest,
    SwitchRequest
};
use std::path::PathBuf;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create Go version manager
    let go_manager = GoManager::new();

    // Install Go 1.21.0
    let install_request = InstallRequest {
        version: "1.21.0".to_string(),
        install_dir: PathBuf::from("/usr/local/go-versions"),
        download_dir: PathBuf::from("/tmp/go-downloads"),
        force: false,
    };

    let version_info = go_manager.install(install_request).await?;
    println!("βœ… Installed Go {}", version_info.version);

    // Switch to that version
    let switch_request = SwitchRequest {
        version: "1.21.0".to_string(),
        base_dir: PathBuf::from("/usr/local/go-versions"),
        global: true,
        force: false,
    };

    go_manager.switch_to(switch_request)?;
    println!("πŸ”„ Switched to Go 1.21.0");

    Ok(())
}

Query Available Versions

use tidepool_version_manager::{go::GoManager, VersionManager};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let go_manager = GoManager::new();

    // Get available versions list
    let available_versions = go_manager.list_available().await?;
    println!("πŸ“‹ Available Go versions ({} total):", available_versions.total_count);

    for version in available_versions.versions.iter().take(10) {
        println!("   - {}", version);
    }

    Ok(())
}

Status Query

use tidepool_version_manager::{go::GoManager, VersionManager, StatusRequest};
use std::path::PathBuf;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let go_manager = GoManager::new();

    let status_request = StatusRequest {
        base_dir: Some(PathBuf::from("/usr/local/go-versions")),
    };

    let status = go_manager.status(status_request)?;

    if let Some(version) = status.current_version {
        println!("🎯 Current Go version: {}", version);

        if let Some(path) = status.install_path {
            println!("πŸ“ Installation path: {}", path.display());
        }

        println!("🌍 Environment variables:");
        for (key, value) in status.environment_vars {
            println!("   {}={}", key, value);
        }
    } else {
        println!("❌ No installed Go version detected");
    }

    Ok(())
}

πŸ”§ Advanced Configuration

Custom Downloader Configuration

use tidepool_version_manager::downloader::{Downloader, DownloadConfig};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create custom download configuration
    let config = DownloadConfig {
        concurrent_connections: 8,        // Number of concurrent connections
        timeout_seconds: 300,             // Timeout in seconds
        enable_chunked_download: true,    // Enable chunked downloads
        max_retries: 3,                   // Maximum retry attempts
        min_chunk_size: 10 * 1024 * 1024, // Minimum chunk size (10MB)
        ..Default::default()
    };

    let downloader = Downloader::with_config(config);

    // Use custom downloader for downloads
    let url = "https://go.dev/dl/go1.21.0.linux-amd64.tar.gz";
    let output_path = "/tmp/go1.21.0.linux-amd64.tar.gz";

    downloader.download(url, output_path, None).await?;
    println!("βœ… Download completed: {}", output_path);

    Ok(())
}

Progress Callbacks

use tidepool_version_manager::downloader::{Downloader, ProgressReporter};

struct MyProgressReporter;

impl ProgressReporter for MyProgressReporter {
    fn report_progress(&self, downloaded: u64, total: Option<u64>) {
        if let Some(total) = total {
            let percentage = (downloaded as f64 / total as f64) * 100.0;
            println!("πŸ“Š Download progress: {:.1}% ({}/{})", percentage, downloaded, total);
        } else {
            println!("πŸ“Š Downloaded: {} bytes", downloaded);
        }
    }

    fn report_error(&self, error: &str) {
        eprintln!("❌ Download error: {}", error);
    }

    fn report_completion(&self) {
        println!("βœ… Download completed!");
    }
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let downloader = Downloader::new();
    let progress_reporter = MyProgressReporter;

    let url = "https://go.dev/dl/go1.21.0.linux-amd64.tar.gz";
    let output_path = "/tmp/go1.21.0.linux-amd64.tar.gz";

    downloader.download(url, output_path, Some(&progress_reporter)).await?;

    Ok(())
}

πŸ—οΈ Architecture Design

Core Components

tidepool-version-manager/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ lib.rs              # Public interfaces and type definitions
β”‚   β”œβ”€β”€ go.rs               # Go version management implementation
β”‚   └── downloader.rs       # Universal downloader module
β”œβ”€β”€ examples/               # Usage examples
└── tests/                  # Integration tests

Feature Overview

  • VersionManager Trait - Unified version management interface, extensible for other runtimes
  • GoManager - Concrete implementation for Go language version management
  • Downloader - High-performance async downloader with resume and progress reporting
  • Cross-platform Support - Unified abstraction for cross-platform symlinks

πŸ§ͺ Running Examples

The project includes several example programs demonstrating different use cases:

# Downloader functionality demo
cargo run --example downloader_test

# Hash verification demo
cargo run --example hash_verification_demo



# Temporary file handling demo
cargo run --example temp_file_demo

# Uninstall protection demo
cargo run --example uninstall_protection_demo

πŸ§ͺ Testing

Run the complete test suite:

# Run all tests
cargo test

# Run specific tests
cargo test go_manager_tests

# Run integration tests
cargo test --test integration_tests

πŸ”„ Version Compatibility

Version Rust Version Features
0.1.5 1.70+ Unified symlink implementation, improved cross-platform compatibility
0.1.4 1.70+ Workspace configuration optimization, code refactoring
0.1.3 1.70+ Go version management, high-performance downloader
0.1.2 1.70+ Basic version management functionality
0.1.1 1.70+ Initial release

🚧 Future Plans

  • Python Version Management - Support for Python/pyenv compatibility
  • Node.js Version Management - Support for Node.js/nvm compatibility
  • Configuration File Support - Project-level version configuration
  • Plugin System - Custom version management extensions
  • Mirror Source Support - Accelerated downloads via domestic mirrors

πŸ“‹ API Documentation

Complete API documentation is available at docs.rs.

Main Types

🀝 Contributing

We welcome all forms of contributions! Please see CONTRIBUTING.md for details.

Development Environment Setup

# Clone repository
git clone https://github.com/Slothtron/tidepool.git
cd tidepool/crates/tidepool-version-manager

# Run tests
cargo test

# Check code formatting
cargo fmt --check

# Run Clippy checks
cargo clippy --all-targets --all-features

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ”— Related Links


Maintained by the Tidepool Project 🌊

Commit count: 0

cargo fmt