https://github.com/fl03/contained
Contained is a research project supporting the on-going efforts of scsys by implementing the proposed harmonic runtime for optimizing the orchestration of cloud-native systems
https://github.com/fl03/contained
binary cloud harmonics research rust
Last synced: 6 months ago
JSON representation
Contained is a research project supporting the on-going efforts of scsys by implementing the proposed harmonic runtime for optimizing the orchestration of cloud-native systems
- Host: GitHub
- URL: https://github.com/fl03/contained
- Owner: FL03
- License: apache-2.0
- Created: 2022-12-02T21:59:04.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-16T23:47:10.000Z (about 2 years ago)
- Last Synced: 2025-06-09T08:15:15.181Z (about 1 year ago)
- Topics: binary, cloud, harmonics, research, rust
- Language: Rust
- Homepage: https://hub.docker.com/r/jo3mccain/contained
- Size: 976 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# contained
[](https://crates.io/crates/contained)
[](https://docs.rs/contained)
[](LICENSE)
***
Welcome to `contained`, a collection of macros and other utilities designed to facilitate the creation and manipulation of so-called wrapper types in Rust. Here, a wrapper type is essentially any object capable of implementing the `#[repr(transparent)]` attribute, such as newtypes, tuple structs, and single-field enums.
## Usage
Before you start using `contained`, make sure to add it as a dependency in your `Cargo.toml` file. You can do this by adding the following lines:
```toml
[dependencies.contained]
features = [
"derive",
]
version = "0.2.x"
```
### Examples
For more detailed examples, please visit the [examples](https://github.com/FL03/contained/tree/main/contained/examples) directory in the repository. Below are some brief examples highlighting certain features of the library.
#### **Example 1**: Using the `Wrapper` derive macro
```rust
use contained::Wrapper;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Wrapper)]
pub struct A(T);
fn main() {
let mut a = A::new(1).map(|x| x + 100);
assert_eq!(a.get(), &101);
a.set(202);
assert_eq!(a.get_mut(), &mut 202);
}
```
#### **Example 2**: Uisng the `fmt_wrapper` macro
```rust
use contained::fmt_wrapper;
#[derive(Clone, Copy, Eq, Hash, PartialEq, PartialOrd)]
pub struct A(T);
#[derive(Clone, Copy, Eq, Hash, PartialEq, PartialOrd)]
pub struct B {
pub value: T,
}
fmt_wrapper! {
impl A {
Debug,
Display,
LowerHex,
UpperHex,
LowerExp,
UpperExp,
Binary,
Octal,
Pointer,
}
}
fmt_wrapper! {
impl B.value {
Debug,
Display,
LowerHex,
UpperHex,
LowerExp,
UpperExp,
Binary,
Octal,
Pointer,
}
}
fn main() {
let a = A::new(255);
let b = B { value: 255 };
println!("A: {a:X}, B: {b:X}");
}
```
## Getting Started
To get started with `contained`, you can check out the [QUICKSTART.md](QUICKSTART.md) file, which provides a step-by-step guide on how to set up your development environment and start using the library.
## License
Licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
## Contribution
Contributions are welcome, however, ensure that you have read the [CONTRIBUTING.md](CONTRIBUTING.md) file before submitting a pull request.
## Security
For any security vulnerabilities, please refer to the [SECURITY.md](SECURITY.md) file for guidance on how to report them.