Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/setup-python@v5 # required for correct CodSpeed integration
with:
python-version: ${{ env.UV_PYTHON }}

Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches:
- main
pull_request:
tags:
- 'v*.*.*'
workflow_dispatch:
Expand Down Expand Up @@ -90,8 +89,7 @@ jobs:
with:
target: ${{ matrix.target }}
manylinux: ${{ matrix.manylinux || 'auto' }}
container: ${{ matrix.container }}
args: --release --out dist --interpreter ${{ matrix.maturin-interpreter || matrix.interpreter || '3.8 3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10 pypy3.11' }} ${{ matrix.extra-build-args }}
args: --release --out dist --interpreter ${{ matrix.interpreter || '3.8 3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10 pypy3.11' }}
rust-toolchain: 1.76.0
docker-options: -e CI

Expand Down Expand Up @@ -129,6 +127,10 @@ jobs:
- name: Checkout repository.
uses: actions/checkout@v4

- uses: actions/setup-python@v5 # required for macos-13 with Python 3.8-3.10... otherwise UV uses PyPy...
with:
python-version: ${{ matrix.interpreter }}

- name: Install UV.
uses: astral-sh/setup-uv@v6
with:
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*.py[cod]

# Generated by Cargo
# will have compiled files and executables
debug/
Expand All @@ -15,6 +17,7 @@ Cargo.lock

# IDE
.idea
*.iml
.vscode

# Python virtual environment
Expand All @@ -30,4 +33,4 @@ __pycache__
.pytest_cache

# Build artifacts
*.so
*.so
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "libipld"
version = "3.0.1"
version = "3.1.0"
edition = "2021"
license = "MIT"
description = "Python binding to the Rust IPLD library"
Expand Down
27 changes: 17 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,32 @@ print(libipld.encode_multibase('u', b'yes mani !'))

### Features

- Decode DAG-CBOR (`decode_dag_cbor(bytes) -> dict`, `decode_dag_cbor_multi(bytes) -> list[dict]`)
- Encode DAG-CBOR (`encode_dag_cbor(obj) -> bytes`)
- Decode CID (`decode_cid(str | bytes) -> dict`). Accepts CID stringified form or CID raw byte form.
- Encode CID (`encode_cid(bytes) -> str`). Encodes CID raw byte form to stringified form.
- Decode Multibase (`decode_multibase(str) -> tuple[str, bytes]`). Returns base and data.
- Encode Multibase (`encode_multibase(str, bytes) -> str`). Accepts base and data.
- Decode CAR (`decode_car(bytes) -> tuple[dict, dict[bytes, dict]]`). Returns a header and blocks mapped by CID. CIDs in raw byte form.
#### 🔗 CID (Content Identifier) Operations
- **`decode_cid(data: str | bytes) -> dict`** - Decode CIDs from string representation (e.g., `'bafy...'`) or raw bytes into structured data containing version, codec, and hash information
- **`encode_cid(data: str | bytes) -> str`** - Encode CID raw bytes to string representation, or return string CIDs as-is

#### 📦 DAG-CBOR (Directed Acyclic Graph CBOR) Operations
- **`decode_dag_cbor(data: bytes) -> Any`** - Decode DAG-CBOR binary data into Python objects (dicts, lists, primitives)
- **`decode_dag_cbor_multi(data: bytes) -> list[Any]`** - Decode multiple concatenated DAG-CBOR objects from a single byte stream
- **`encode_dag_cbor(data: Any) -> bytes`** - Encode Python objects into DAG-CBOR binary format

## Requirements
#### 🌐 Multibase Operations
- **`decode_multibase(data: str) -> tuple[str, bytes]`** - Decode multibase-encoded strings, returning the base identifier and decoded data
- **`encode_multibase(code: str, data: str | bytes) -> str`** - Encode data using specified multibase encoding (e.g., base58btc with code `'u'`)

#### 🚗 CAR (Content Addressable Archives) Operations
- **`decode_car(data: bytes) -> tuple[dict, dict[bytes, dict]]`** - Decode CAR files into header metadata and a mapping of CID bytes to block data

### Requirements

- Python 3.8 or higher.

## Installing
### Installing

You can install or upgrade `libipld` via

```bash
pip install libipld
pip install -U libipld
```

### Contributing
Expand Down
2 changes: 1 addition & 1 deletion python/libipld/_libipld.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def decode_multibase(data: str) -> tuple[str, bytes]:
"""


def encode_multibase(code: str, data: bytes | str) -> str:
def encode_multibase(code: str, data: str | bytes) -> str:
"""Encode data using multibase.

Args:
Expand Down