{"id":17875959,"url":"https://github.com/bnjjj/chicon-rs","last_synced_at":"2025-05-08T17:01:38.121Z","repository":{"id":56619142,"uuid":"194717780","full_name":"bnjjj/chicon-rs","owner":"bnjjj","description":"A file abstraction system for Rust","archived":false,"fork":false,"pushed_at":"2022-10-24T07:12:34.000Z","size":100,"stargazers_count":74,"open_issues_count":5,"forks_count":11,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-08T17:00:00.775Z","etag":null,"topics":["filesystem","hacktoberfest","rust","s3","sftp","ssh"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bnjjj.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":"2019-07-01T17:44:13.000Z","updated_at":"2024-11-14T19:56:18.000Z","dependencies_parsed_at":"2022-08-15T22:01:05.256Z","dependency_job_id":null,"html_url":"https://github.com/bnjjj/chicon-rs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnjjj%2Fchicon-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnjjj%2Fchicon-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnjjj%2Fchicon-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnjjj%2Fchicon-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bnjjj","download_url":"https://codeload.github.com/bnjjj/chicon-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253112071,"owners_count":21856070,"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":["filesystem","hacktoberfest","rust","s3","sftp","ssh"],"created_at":"2024-10-28T11:26:19.613Z","updated_at":"2025-05-08T17:01:38.072Z","avatar_url":"https://github.com/bnjjj.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Chicon\n\n[![Version](https://img.shields.io/crates/v/chicon.svg)](https://crates.io/crates/chicon)\n[![Documentation](https://docs.rs/chicon/badge.svg)](https://docs.rs/chicon)\n\nA file abstraction system for Rust.  Chicon is a library meant to provide a simple, uniform and universal API interacting with any filesystem. Chicon behaves as an abstraction layer providing traits, types and methods. The main `FileSystem` trait is based on the usage of [`std::fs::*`](https://doc.rust-lang.org/stable/std/fs/) in order to be transparent when switching from a physical filesystem to a virtual one like S3, SFTP, SSH or in-memory. Chicon is suitable for any situation where storing directories and files on different filesystems is needed. Memory file system can be appropriate to write tests in order to have a faster execution than with an IO filesystem.\n\n## Examples\n\n### Use S3 as backend to create a file\n\n```rust\nuse std::io::prelude::*;\nuse chicon::{DirEntry, File, FileSystem, S3FileSystem};\nlet s3_fs = S3FileSystem::new(\n     String::from(\"my_access_key_id\"),\n     String::from(\"secret_access_key\"),\n     String::from(\"my_bucket\"),\n     String::from(\"my_region\"),\n     String::from(\"http://127.0.0.1\"), // endpoint\n);\nlet mut file = s3_fs.create_file(\"test.test\").unwrap()\nfile.write_all(String::from(\"here is a test\").as_bytes()).unwrap();\nfile.sync_all().unwrap();\nlet mut content: String = String::new();\nfile.read_to_string(\u0026mut content).unwrap();\nassert_eq!(content, String::from(\"here is a test\"));\ns3_fs.remove_file(\"test.test\").unwrap(); // To delete the file\n```\n\n### Use SFTP as backend to create a file\n\n\u003e You just need to change from `S3FileSystem::new` to `SFTPFileSystem::new`.\n\n```rust\nuse std::io::prelude::*;\nuse chicon::{DirEntry, File, FileSystem, SFTPFileSystem};\nlet sftp_fs = SFTPFileSystem::new(\n    String::from(\"127.0.0.1:2222\"), // host:port\n    String::from(\"foo\"), // user\n    None, // Some(\"passphrase\") if you have a passphrase configured on your ssh key\n    \"/Users/foo/.ssh/my_private_key\", // ABSOLUTE path to private key\n    \"/Users/foo/.ssh/my_public_key.pub\" // ABSOLUTE path to public key\n);\nlet mut file = sftp_fs.create_file(\"test.test\").unwrap()\nfile.write_all(String::from(\"here is a test\").as_bytes()).unwrap();\nfile.sync_all().unwrap();\nlet mut content: String = String::new();\nfile.read_to_string(\u0026mut content).unwrap();\nassert_eq!(content, String::from(\"here is a test\"));\n```\n\n### Use SSH as backend to read a file\n\n```rust\nuse std::io::prelude::*;\nuse chicon::{DirEntry, File, FileSystem, SSHFileSystem};\nlet ssh_fs = SSHFileSystem::new(\n    String::from(\"127.0.0.1:2222\"), // host:port\n    String::from(\"foo\"), // user\n    None, // Some(\"passphrase\") if you have a passphrase configured on your ssh key\n    \"/Users/foo/.ssh/my_private_key\", // ABSOLUTE path to private key\n    \"/Users/foo/.ssh/my_public_key.pub\" // ABSOLUTE path to public key\n);\nlet mut file = ssh_fs.open_file(\"share/myfile.txt\").unwrap();\nlet mut buffer = String::new();\nfile.read_to_string(\u0026mut buffer).unwrap();\nprintln!(\"Here is the content of your file: {}\", buffer);\n```\n\n### Use OS (local filesystem) as backend to create and read a directory\n\n```rust\nuse std::io::prelude::*;\nuse chicon::{DirEntry, File, FileType, FileSystem, OsFileSystem};\nlet os_fs = OsFileSystem::new();\nos_fs.create_dir_all(\"testreaddir/test\").unwrap();\nos_fs.create_file(\"testreaddir/mytest.test\").unwrap();\nlet dir_entries = os_fs.read_dir(\"testreaddir\").unwrap();\nassert!(!dir_entries.is_empty())\nassert_eq!(dir_entries.len(), 2)\nassert_eq!(\n    dir_entries.get(0).unwrap().path().unwrap(),\n    PathBuf::from(\"testreaddir/test\")\n);\nassert_eq!(\n    dir_entries.get(0).unwrap().file_type().unwrap(),\n    FileType::Directory\n);\nstd::fs::remove_dir_all(\"testreaddir\").unwrap(); // To remove dir and all entries inside\n```\n\n\u003e If you need more examples, checkout the tests in the source code on the GitHub repository.\n\n## Roadmap\n\n+ implement swift as a new backend\n+ refactor with more idiomatic Rust stuff\n+ add async support\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbnjjj%2Fchicon-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbnjjj%2Fchicon-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbnjjj%2Fchicon-rs/lists"}