| Title: | R Bindings to the 'Rust' 'IPLD' Library |
|---|---|
| Description: | Provides R bindings to decode DAG-CBOR (Directed Acyclic Graph Concise Binary Object Representation) encoded data, CIDs (Content Identifiers), and CAR (Content Addressable aRchive) files using the 'Rust' 'IPLD' (InterPlanetary Linked Data) library <https://github.com/ipld/libipld>. This is especially useful for working with data from 'IPFS' (InterPlanetary File System) and 'AtProto' (Bluesky) applications. |
| Authors: | Johannes B. Gruber [aut, cre] (ORCID: <https://orcid.org/0000-0001-9177-1772>), Ilya Siamionau [ctb] (Author of the original python-libipld Rust implementation) |
| Maintainer: | Johannes B. Gruber <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.1 |
| Built: | 2026-05-27 22:38:59 UTC |
| Source: | https://github.com/cran/libipldr |
Provides R bindings to decode DAG-CBOR (Directed Acyclic Graph Concise Binary Object Representation) encoded data, CIDs (Content Identifiers), and CAR (Content Addressable aRchive) files using the 'Rust' 'IPLD' (InterPlanetary Linked Data) library https://github.com/ipld/libipld. This is especially useful for working with data from 'IPFS' (InterPlanetary File System) and 'AtProto' (Bluesky) applications.
Maintainer: Johannes B. Gruber [email protected] (ORCID)
Authors:
Johannes B. Gruber [email protected] (ORCID)
Other contributors:
Ilya Siamionau (Author of the original python-libipld Rust implementation) [contributor]
Useful links:
This function decodes a CAR file from a raw vector, extracting the header and blocks.
decode_car(data)decode_car(data)
data |
A raw vector containing a CAR file |
A list with header information and decoded blocks
car_file <- system.file("extdata", "sample.car", package = "libipldr") car_data <- readBin(car_file, what = "raw", n = file.size(car_file)) decode_car(car_data)car_file <- system.file("extdata", "sample.car", package = "libipldr") car_data <- readBin(car_file, what = "raw", n = file.size(car_file)) decode_car(car_data)
This function decodes a CID string into its components (version, codec, and hash).
decode_cid(cid_str)decode_cid(cid_str)
cid_str |
A string containing a valid CID |
A list with CID components
# Decode a CID: cid_info <- decode_cid("bafyreib775pirw4o3rz4iwdjwi3rz7q4z5t4xjyfrwnk2yukhzo2wyr4ye")# Decode a CID: cid_info <- decode_cid("bafyreib775pirw4o3rz4iwdjwi3rz7q4z5t4xjyfrwnk2yukhzo2wyr4ye")
This function decodes a raw vector containing DAG-CBOR encoded data into an R object. DAG-CBOR is a deterministic subset of the CBOR format, used by IPFS and AtProto (Bluesky) for data representation.
decode_dag_cbor(data)decode_dag_cbor(data)
data |
A raw vector containing DAG-CBOR encoded data |
An R object representing the decoded data
# Decode a simple DAG-CBOR map {"a": "Hello", "b": "World!"} cbor_data <- as.raw(c( 0xa2, 0x61, 0x61, 0x65, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x61, 0x62, 0x66, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x21 )) decode_dag_cbor(cbor_data)# Decode a simple DAG-CBOR map {"a": "Hello", "b": "World!"} cbor_data <- as.raw(c( 0xa2, 0x61, 0x61, 0x65, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x61, 0x62, 0x66, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x21 )) decode_dag_cbor(cbor_data)
This function decodes multiple consecutive DAG-CBOR objects from a single raw vector. The returned list includes a 'bytes_consumed' attribute indicating how many bytes from the beginning of the input were successfully processed. This is useful for streaming applications where you need to know where to continue reading.
decode_dag_cbor_multi(data)decode_dag_cbor_multi(data)
data |
A raw vector containing multiple DAG-CBOR encoded objects |
A list of R objects, each representing a decoded DAG-CBOR object
# Decode two consecutive DAG-CBOR objects from a single byte stream cbor_data <- as.raw(c( 0xa2, 0x61, 0x61, 0x65, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x61, 0x62, 0x66, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x21, 0xa1, 0x61, 0x63, 0x01 )) results <- decode_dag_cbor_multi(cbor_data) attr(results, "bytes_consumed")# Decode two consecutive DAG-CBOR objects from a single byte stream cbor_data <- as.raw(c( 0xa2, 0x61, 0x61, 0x65, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x61, 0x62, 0x66, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x21, 0xa1, 0x61, 0x63, 0x01 )) results <- decode_dag_cbor_multi(cbor_data) attr(results, "bytes_consumed")