{"id":21500258,"url":"https://github.com/clucompany/cluextio","last_synced_at":"2025-07-15T21:32:01.727Z","repository":{"id":40605215,"uuid":"156695280","full_name":"clucompany/cluExtIO","owner":"clucompany","description":"Syntactic sugar extends I/O capabilities.","archived":false,"fork":false,"pushed_at":"2019-08-23T17:11:50.000Z","size":81,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-19T11:14:53.639Z","etag":null,"topics":["clucompany","cluextio","extio","library","rust-library"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/clucompany.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-08T11:16:09.000Z","updated_at":"2022-06-27T01:54:44.000Z","dependencies_parsed_at":"2022-09-26T20:01:08.981Z","dependency_job_id":null,"html_url":"https://github.com/clucompany/cluExtIO","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clucompany%2FcluExtIO","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clucompany%2FcluExtIO/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clucompany%2FcluExtIO/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clucompany%2FcluExtIO/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clucompany","download_url":"https://codeload.github.com/clucompany/cluExtIO/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226073199,"owners_count":17569485,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clucompany","cluextio","extio","library","rust-library"],"created_at":"2024-11-23T17:23:07.445Z","updated_at":"2024-11-23T17:23:08.073Z","avatar_url":"https://github.com/clucompany.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cluExtIO\n\n[![Build Status](https://travis-ci.org/clucompany/cluExtIO.svg?branch=master)](https://travis-ci.org/clucompany/cluExtIO)\n[![Apache licensed](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](./LICENSE)\n[![crates.io](http://meritbadge.herokuapp.com/cluExtIO)](https://crates.io/crates/cluExtIO)\n[![Documentation](https://docs.rs/cluExtIO/badge.svg)](https://docs.rs/cluExtIO)\n\nSyntactic sugar extends I/O capabilities.\n\n\n# Capabilities:\n1. EmptyWrite - Empty \"Write\" that does nothing.\n2. UnionWrite - Possibility to combine several \"Write\" into one record.\n3. MutexWrite - Combining Mutex and Write for multi-threaded access.\n4. LockWrite - The trait extends the capabilities of the standard Write, adds lock methods.\n5. FlushDropWrite - An implementation of \"Trait Write\", which calls the flush () method on drop. \n6. FlushLockWrite - An implementation of \"Trait Write\" that calls the flush() method when removing a lock.\n7. NotChanWrite - Unchangeable \"Trait Write\".\n...\n\n# Use\n\n1. UnionWrite\n\n```rust\nextern crate cluExtIO;\n\nuse std::io::Write;\nuse cluExtIO::UnionWriteConst;\nuse std::fs::File;\n\npub fn main() {\n\n\t\t let file1 = File::create(\"/tmp/1.out\").unwrap();\n\t\t //file1 - `Write trait`\n\n\t\t let file2 = File::create(\"/tmp/2.out\").unwrap();\n\t\t //file2 - `Write trait`\n\n\t\t let write = file1.union(file2);\n\t\t //UnionWrite - `FILE1+FILE2`\n\n\n\t\t my_function(write).unwrap();\n}\n\nfn my_function\u003cW: Write\u003e(mut w: W) -\u003e Result\u003c(), std::io::Error\u003e {\n\t\t w.write_fmt(format_args!(\"#@{} {}\\n\", 1, \"Test\"))?;\n\t\t w.write_fmt(format_args!(\"#@{} {}\\n\", 2, \"MyString\"))?;\n\t\t w.write_fmt(format_args!(\"#@{} {}\\n\", 3, \"MyString\"))?;\n\n\t\t Ok( () )\n}\n```\n\t\t\n2. LockWrite\n\n```rust\nextern crate cluExtIO;\n\nuse cluExtIO::LockWrite;\nuse std::io::Write;\n\npub fn main() {\n\tlet out = std::io::stdout();\n\n\tmy_function(\u0026out, 0, \"No eND:)\").unwrap();\n\n\tout.lock_fn(|mut l| {\n\t\t\tl.write(b\"End.\\n\")\n\t}).unwrap();\n}\n\nfn my_function\u003c'a, W: LockWrite\u003c'a\u003e\u003e(raw_write: \u0026'a W, n: usize, str: \u0026'static str) -\u003e Result\u003c(), std::io::Error\u003e {\n\tlet mut lock = raw_write.lock();\n\n\tlock.write_fmt(format_args!(\"#@{} {}\\n\", n, \"Test\"))?;\n\tlock.write_fmt(format_args!(\"#@{} {}\\n\", n+1, \"MyString\"))?;\n\tlock.write_fmt(format_args!(\"#@{} ~{}\\n\", n+2, str))?;\n\n\tOk( () )\n}\n```\n\n3. Threads\n\n```rust\nextern crate cluExtIO;\n\nuse std::io::stdout;\nuse cluExtIO::UnionWriteConst;\nuse cluExtIO::LockWrite;\nuse cluExtIO::MutexWrite;\nuse cluExtIO::FlushLockWrite;\nuse cluExtIO::NotChanWrite;\nuse std::io::Write;\nuse std::fs::File;\nuse std::sync::Arc;\nuse std::sync::Barrier;\nuse std::thread;\n\npub fn main() {\n\t\t let arc_out = Arc::new({\t  \n\t\t\t\tlet out = stdout();\n\n\t\t\t\tlet file = FlushLockWrite::new(MutexWrite::new(File::create(\"/tmp/file.out\").unwrap()));\n\t\t\t\t//Contains the implementation of LockWrite. Safe for inter-thread space.\n\t\t\t\t//+ Additional self-cleaning after destroying Lock\n\n\t\t\t\tlet file2 = FlushLockWrite::new(MutexWrite::new(File::create(\"/tmp/file2.out\").unwrap()));\n\t\t\t\t//Contains the implementation of LockWrite. Safe for inter-thread space.\n\t\t\t\t//+ Additional self-cleaning after destroying Lock\n\n\t\t\t\tout.union(file).union(file2)\n\t\t }); //Combined `LockWrite` with lock function. OUT_PIPE + FILE_PIPE(2) = UNION_SAFE_PIPE\n\n\n\t\t let barrier = Arc::new(Barrier::new(5 + 1));\n\n\t\t for num_thread in 0..5 {\n\t\t\t\tlet barrier = barrier.clone();\n\t\t\t\tlet arc_out = arc_out.clone();\n\t\t\t\tthread::spawn(move || {\n\n\t\t\t\t\t\tarc_out.lock_fn(|mut lock| {\n\t\t\t\t\t\t\t\tlock.write_fmt(format_args!(\"#@{} {}\\n\", num_thread, \"Thread #OK\")).unwrap();\n\t\t\t\t\t\t\t\tlock.write_fmt(format_args!(\"#@{} {}\\n\", num_thread, \"Thread #T\")).unwrap();\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tbarrier.wait();\n\t\t\t\t});\n\t\t }\n\n\t\t barrier.wait();\n\n\t\t arc_out.write_fmt(format_args!(\"#@{} {}\\n\", 999, \"Thread pull end.\")).unwrap();\n\t\t //Arc\u003cUnionWrite\u003e, auto lock methods. (NotChanWrite)\n\n\t\t // /tmp/file.out+\n\t\t // /tmp/file.out+\n}\n```\n\n\n# License\n\nCopyright 2018 #UlinProject Денис Котляров\n\nLicensed under the Apache License, Version 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclucompany%2Fcluextio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclucompany%2Fcluextio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclucompany%2Fcluextio/lists"}