rivalz_client

Crates.iorivalz_client
lib.rsrivalz_client
version0.1.2
sourcesrc
created_at2024-06-20 03:36:54.956636
updated_at2024-06-20 03:41:21.853467
descriptionA Rust client for interacting with the Rivalz API, allowing file uploads and retrieval of IPFS hashes.
homepagehttps://github.com/ngocbd/rivalz-client
repositoryhttps://github.com/ngocbd/rivalz-client
max_upload_size
id1277539
size39,134
Bui Dinh Ngoc (ngocbd)

documentation

https://docs.rs/rivalz_client

README

RivalzClient

RivalzClient is a Rust client for interacting with the Rivalz API. This client allows you to upload files to IPFS and retrieve their IPFS hash.

Features

  • Upload files using multipart form data.
  • Retrieve the IPFS hash of uploaded files.
  • Robust error handling for network issues, server errors, and file accessibility.

Getting Started

Prerequisites

  • Rust (version 1.50 or later)
  • A Rivalz API secret token.

Installation

To use the RivalzClient library in your project, add the following to your Cargo.toml:

[dependencies]
rivalz_client = "0.1.0"

Usage

  1. Set your Rivalz API secret token as an environment variable:

    export SECRET_TOKEN="your_secret_token"
    
  2. Create an instance of RivalzClient and use it to upload a file:

    use rivalz_client::RivalzClient;
    
    fn main() {
        let client = RivalzClient::new(None);
        let file_path = "path/to/your/file.txt";
        
        match client.upload_file(file_path) {
            Ok(ipfs_hash) => println!("File uploaded successfully! IPFS hash: {}", ipfs_hash),
            Err(e) => eprintln!("Failed to upload file: {}", e),
        }
    }
    

Building from Source

To build RivalzClient from source, follow these steps:

  1. Clone the repository:

    git clone https://github.com/yourusername/rivalz-client.git
    cd rivalz-client
    
  2. Build the project:

    cargo build
    
  3. Run tests:

    cargo test
    

Publishing

To publish a new version of RivalzClient to crates.io, follow these steps:

  1. Update the version number in Cargo.toml.

  2. Login to crates.io:

    cargo login
    
  3. Publish the package:

    cargo publish
    

Contributing

We welcome contributions to RivalzClient! To contribute:

  1. Fork the repository.

  2. Create a new branch for your feature or bugfix:

    git checkout -b my-feature-branch
    
  3. Make your changes and commit them:

    git commit -am 'Add new feature'
    
  4. Push to the branch:

    git push origin my-feature-branch
    
  5. Create a new Pull Request on GitHub.

Submitting Issues

If you find a bug or have a feature request, please create an issue on GitHub.

Code of Conduct

This project adheres to the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code.

License

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

Commit count: 0

cargo fmt