# ferripfs-pinning
IPFS content pinning - prevent blocks from being garbage collected.
> **Note**: This crate is part of [ferripfs](https://codeberg.org/dpp/ferripfs), a Rust port of [Kubo](https://github.com/ipfs/kubo) (the Go IPFS implementation). The implementation follows Kubo's [boxo/pinning](https://github.com/ipfs/boxo/tree/main/pinning) package. See [Kubo's pinning documentation](https://docs.ipfs.tech/concepts/persistence/) for conceptual details.
## Features
- **Pin Types**: Direct, Recursive, and Indirect pins
- **Named Pins**: Associate names with pinned content
- **Pin Verification**: Verify all pinned blocks exist
- **GC Protection**: Pinned content survives garbage collection
## Usage
```rust
use ferripfs_pinning::{BlockstorePinner, PinMode};
// Create a pinner
let pinner = BlockstorePinner::new("/path/to/repo")?;
// Add a recursive pin (pins block and all references)
pinner.pin_with_name(&cid, PinMode::Recursive, Some("my-data"))?;
// Add a direct pin (pins only the specified block)
pinner.pin_with_name(&cid, PinMode::Direct, None)?;
// List all pins
for pin in pinner.list_pins(None)? {
println!("{}: {} ({})", pin.cid, pin.mode, pin.name.unwrap_or_default());
}
// Remove a pin
pinner.unpin(&cid)?;
// Verify all pins are intact
let results = pinner.verify()?;
for result in results {
if !result.ok {
println!("Missing block: {}", result.cid);
}
}
```
## Pin Types
| `Direct` | Only the specified block is pinned |
| `Recursive` | Block and all referenced blocks are pinned |
| `Indirect` | Block is referenced by a recursive pin |
## License
Dual-licensed under MIT and Apache-2.0.