plyne

Crates.ioplyne
lib.rsplyne
version0.0.2
created_at2025-09-01 01:20:31.400765+00
updated_at2025-09-11 03:04:30.318349+00
descriptionBased pipeline of async task system
homepage
repositoryhttps://github.com/xiao-e-yun/Plyne
max_upload_size
id1819016
size24,162
小惡運 (xiao-e-yun)

documentation

README

Plyne

Based pipeline of async task system

  • Simple
  • Type Safe
  • Zero Cost

Usage

Install

cargo add plyne

Define tasks

use plyne::define_tasks;

define_tasks! {
    TaskSystem // Name of the task system
    pipelines { // Define pipelines
        APipeline: Vec<u8>, // you can use APipelineInput or APipelineOutput
    }
    vars { // Define variables
        Dataset: Arc<Vec<u8>>, // Avoid larger types
        Config: config::Config, // Avoid same name as struct
    }
    tasks { // Define tasks
        load_data,
        parse_data,
    }
}

async fn load_data(dataset: dataset, pipeline: APipelineInput) -> String {
    for data in dataset.chunks(8) {
        pipeline.send(chunk.to_vec());
    }
}

async fn parse_data(a_pipeline: APipelineOutput, config: Config) -> Vec<u8> {
    let mut results = String::new();
    while let Some(data) = a_pipeline.recv().await {
        ... // parse data using config
    }
}

Execute tasks

#[tokio::main]
async fn main() {
    TaskSystem::new(
        vec![13,31,31,32,15,32,14,15,22,22,66,23,17,61]
    ).execute().await;
}
Commit count: 3

cargo fmt