9个不稳定版本 (3个破坏性版本)
| 0.8.0 | 2023年6月23日 | 
|---|---|
| 0.7.2 | 2023年8月19日 | 
| 0.7.1 | 2023年5月22日 | 
| 0.6.3 | 2023年4月5日 | 
| 0.5.0 | 2022年12月20日 | 
#2 in #genesys-go
每月112次下载
在  3 crates 中使用
125KB
 2.5K  SLoC
Shadow Drive Rust
Rust SDK,用于GenesysGo的Shadow Drive,一个去中心化存储网络。
在 crates.io 上可用。
安装
将crate添加到您的 Cargo.toml。
shadow-drive-rust = "0.7.1"
示例
    //init tracing.rs subscriber
    tracing_subscriber::fmt()
        .with_env_filter("off,shadow_drive_rust=debug")
        .init();
    //load keypair from file
    let keypair = read_keypair_file(KEYPAIR_PATH).expect("failed to load keypair at path");
    //create shdw drive client
    let shdw_drive_client = ShadowDriveClient::new(keypair, "https://ssc-dao.genesysgo.net");
    //derive the storage account pubkey
    let pubkey = keypair.pubkey();
    let (storage_account_key, _) =
        shadow_drive_rust::derived_addresses::storage_account(&pubkey, 0);
    // read files in directory
    let dir = tokio::fs::read_dir("multiple_uploads")
    .await
    .expect("failed to read multiple uploads dir");
    // create Vec of ShadowFile structs for upload
    let mut files = tokio_stream::wrappers::ReadDirStream::new(dir)
        .filter(Result::is_ok)
        .and_then(|entry| async move {
            Ok(ShadowFile::file(
                entry
                    .file_name()
                    .into_string()
                    .expect("failed to convert os string to regular string"),
                entry.path(),
            ))
        })
        .collect::<Result<Vec<_>, _>>()
        .await
        .expect("failed to create shdw files for dir");
    // Bytes are also supported
    files.push(ShadowFile::bytes(
        String::from("buf.txt"),
        &b"this is a buf test"[..],
    ));
    // kick off upload
    let upload_results = shdw_drive_client
        .upload_multiple_files(&storage_account_key, files)
        .await
        .expect("failed to upload files");
    //profit
    println!("upload results: {:#?}", upload_results);
更多示例可以在 example 目录中找到。
依赖关系
~77MB
~1.5M SLoC