# cmp_rs
ESP-IDF prebuilt component that ships a self-contained Rust staticlib
exposing a base64 encode demo. The C base64 implementation is bundled
inside the `.a` at Rust build time, so this component has no source files
of its own.
## Layout
```
cmp_rs/
├── CMakeLists.txt
├── idf_component.yml
├── LICENSE
├── README.md
├── include/
│ └── esp32s3_base64.h
└── lib/
└── esp32s3/
└── libesp32s3_base64.a
```
To support more chips, build the Rust project for each target and drop the
resulting `.a` into a sibling subdir (`lib/esp32/`, `lib/esp32c3/`, …).
## Usage
In a consuming ESP-IDF project, add to `main/idf_component.yml`:
```yaml
dependencies:
<namespace>/cmp_rs: "^0.1.0"
```
Then call into it from `app_main`:
```c
#include "esp32s3_base64.h"
void app_main(void) {
rust_base64_demo();
}
```
## Rebuilding the staticlib
```sh
cd /path/to/esp32s3-base64
cargo build --release
cp target/xtensa-esp32s3-espidf/release/libesp32s3_base64.a \
/path/to/cmp_rs/lib/esp32s3/
```
The `.a` is self-contained — `base64_encoder.c` is compiled into it via the
`cc` crate during the cargo build.
## Publishing
```sh
pip install idf-component-manager
export IDF_COMPONENT_API_TOKEN=<token-from-components.espressif.com>
cd /Users/karanrajput/esp-rs/cmp_rs
compote component upload --namespace <your-namespace> --name cmp_rs
```
idf.py add-dependency "jays0223/cmp_rs^0.0.1"