···11# plcbundle-rs
2233-Main purpose of this package is to provide universal and simple interface, as Rust library or C/GO bindings for manipulation with plcbundle repository.
33+A high-performance [plcbundle](https://tangled.org/atscan.net/plcbundle/) management tool and library written in Rust.
44+55+## Overview
66+77+`plcbundle-rs` provides a universal and efficient interface for managing PLC bundle repositories. It offers:
88+99+- **Rust Library**: Core functionality with a clean, high-level API
1010+- **CLI Tool**: Comprehensive command-line interface for bundle operations
1111+- **HTTP Server**: Built-in server with WebSocket support
1212+- **FFI Bindings**: C and Go bindings for cross-language integration
1313+1414+## Features
1515+1616+- ✅ **Bundle Management**: Load, inspect, and manipulate PLC bundles
1717+- ✅ **DID Resolution**: Resolve DIDs and query operations
1818+- ✅ **Synchronization**: Sync with remote PLC servers
1919+- ✅ **Verification**: Verify bundle integrity and operation chains
2020+- ✅ **Query & Export**: Flexible querying and export capabilities
2121+- ✅ **Index Management**: Efficient DID indexing and lookup
2222+- ✅ **Performance**: Memory-mapped files, parallel processing, and optimized data structures
2323+2424+## Installation
2525+2626+### From Source
2727+2828+```bash
2929+# Clone the repository
3030+git clone https://tangled.org/atscan.net/plcbundle-rs
3131+cd plcbundle-rs
3232+3333+# Build with default features (CLI)
3434+cargo build --release
3535+3636+# Install the CLI tool
3737+cargo install --path .
3838+```
3939+4040+### As a Library
4141+4242+Add to your `Cargo.toml`:
4343+4444+```toml
4545+[dependencies]
4646+plcbundle = "0.9"
4747+```
4848+4949+## Quick Start
5050+5151+### CLI Usage
5252+5353+```bash
5454+# Initialize a new repository
5555+plcbundle init --origin https://plc.directory
5656+5757+# Sync with remote server
5858+plcbundle sync
5959+6060+# Query operations for a DID
6161+plcbundle did <did:plc:...>
6262+6363+# Export bundles
6464+plcbundle export --format ndjson
6565+6666+# Start HTTP server
6767+plcbundle server --port 8080
6868+6969+# View repository status
7070+plcbundle status
7171+```
7272+7373+### Library Usage
7474+7575+```rust
7676+use plcbundle::{BundleManager, ManagerOptions};
7777+7878+// Initialize manager
7979+let manager = BundleManager::new(
8080+ "/path/to/bundles",
8181+ ManagerOptions::default()
8282+)?;
8383+8484+// Resolve a DID
8585+let doc = manager.resolve_did("did:plc:example")?;
8686+8787+// Query operations
8888+let ops = manager.get_did_operations("did:plc:example")?;
8989+9090+// Load a bundle
9191+let result = manager.load_bundle(1, Default::default())?;
9292+```
9393+9494+## Project Structure
9595+9696+```
9797+plcbundle-rs/
9898+├── src/
9999+│ ├── lib.rs # Library entry point
100100+│ ├── manager.rs # Core BundleManager API
101101+│ ├── cli/ # CLI commands
102102+│ ├── server/ # HTTP server implementation
103103+│ └── ... # Core modules
104104+├── bindings/
105105+│ └── go/ # Go FFI bindings
106106+├── docs/ # Documentation
107107+│ ├── API.md # API reference
108108+│ ├── BUNDLE_FORMAT.md # Bundle format specification
109109+│ └── ...
110110+└── tests/ # Integration tests
111111+```
112112+113113+## Documentation
114114+115115+- [API Documentation](docs/API.md) - Complete API reference
116116+- [Bundle Format](docs/BUNDLE_FORMAT.md) - Bundle file format specification
117117+- [Logging](docs/LOGGING.md) - Logging configuration
118118+- [Specification](docs/specification.md) - PLC specification
119119+120120+## Development
121121+122122+### Building
123123+124124+```bash
125125+# Build with all features
126126+cargo build --all-features
127127+128128+# Run tests
129129+cargo test
130130+131131+# Generate documentation
132132+cargo doc --open
133133+```
134134+135135+### Features
136136+137137+- `cli` (default): Enables CLI functionality
138138+- `server`: Enables HTTP server and WebSocket support
139139+140140+### Running Tests
141141+142142+```bash
143143+# Run all tests
144144+cargo test
145145+146146+# Run specific test suite
147147+cargo test --test manager
148148+cargo test --test server --features server
149149+```
41505151## 🚨 Important for Contributors and AI Assistants
61527153**Please read [`RULES.md`](RULES.md) before contributing or generating code.**
815499-Key principle: **CLI commands and server code NEVER open bundle files directly** - all operations go through the `BundleManager` API.155155+Key principle: **CLI commands and server code NEVER open bundle files directly** - all operations go through the `BundleManager` API.
156156+157157+## License
158158+159159+Dual-licensed under MIT OR Apache-2.0
160160+161161+## Author
162162+163163+Tree <tree@tree.fail>
164164+165165+## Repository
166166+167167+https://tangled.org/atscan.net/plcbundle-rs