kxio/README.md

92 lines
2.6 KiB
Markdown
Raw Normal View History

2024-11-08 19:46:19 +00:00
# kxio
2024-04-08 16:58:18 +01:00
`kxio` is a Rust library that provides injectable `FileSystem`, `Network` and
`Print` resources to enhance the testability of your code. By abstracting
system-level interactions, `kxio` enables easier mocking and testing of code
that relies on file system and network operations.
2024-11-08 19:46:19 +00:00
## Features
2024-11-08 19:46:19 +00:00
- **Filesystem Abstraction**
- **Network Abstraction**
- **Print Abstraction**
2024-11-08 19:46:19 +00:00
- **Enhanced Testability**
2024-11-08 19:46:19 +00:00
## Filesystem
The Filesystem module offers a clean abstraction over `std::fs`, the standard
file system operations. For comprehensive documentation and usage examples,
2024-11-09 21:07:43 +00:00
please refer to <https://docs.rs/kxio/latest/kxio/fs/>.
2024-11-08 19:46:19 +00:00
### Key Filesystem Features:
- File reading and writing
- Directory operations
- File metadata access
- Fluent API for operations like `.reader().bytes()`
## Network
The Network module offers a testable interface over the `reqwest` crate. For
comprehensive documentation and usage examples, please refer to
<https://docs.rs/kxio/latest/kxio/net/>
## Print
The Print module provides three implementations of the `Printer` trait:
- `StandardPrint` - behaves as normal, printing to `STDOUT` and `STDERR`
- `NullPrint` - swallows all prints, outputting nothing
- `TestPrint` - captures all print output and makes it available for assertions in tests
It also provides macros to use with each:
- `kxprintln`
- `kxprint`
- `kxeprintln`
- `kxeprint`
They are analogous to the `std` macros: `println`, `print`, `eprintln` and `eprint` respectively.
Each of the `kx{e}print{ln}` macros takes a reference to an instance of the `Printer` trait as the first parameter.
For comprehensive documentation and usage examples, please refer to <https://docs.rs/kxio/latest/kxio/print/>
2024-11-08 19:46:19 +00:00
## Getting Started
Add `kxio` to your `Cargo.toml`:
```toml
[dependencies]
kxio = "x.y.z"
```
## Usage
See the example [get.rs](./examples/get.rs) for an annotated example on how to use the `kxio` library.
It covers both the `net` and `fs` modules.
## Development
- The project uses [Cargo Mutants](https://crates.io/crates/cargo-mutants) for mutation testing.
- [ForgeJo Actions](https://forgejo.org/docs/next/user/actions/) are used for continuous testing and linting.
## Contributing
Contributions are welcome! Please check our [issue tracker](https://git.kemitix.net/kemitix/kxio/issues) for open tasks or
submit your own ideas.
## License
This project is licensed under the terms specified in the `LICENSE` file in the
repository root.
## Acknowledgements
- Built with Rust
---
For more information, bug reports, or feature requests, please visit our [repository](https://git.kemitix.net/kemitix/kxio).