Skip to content

Commit c9019e9

Browse files
docs: add information and examples to adr readme
1 parent 53b59d5 commit c9019e9

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

docs/adr/01-naming.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
# Naming convention
2+
23
Producing language bindings potentially requires renaming a number of types and methods, and this document outlines the approach we have decided to take when thinking through this problem for bdk-ffi libraries.
34

45
## Context and Problem Statement
6+
57
The tool we use to produce language bindings for bdk-ffi libraries is [uniffi]. While the library is powerful, it also comes with some caveats. Some of those include the inability to expose to foreign bindings Rust-specific types like tuples, and the inability to expose generics. This means that at least _some_ wrapping and transforming of certain things are required between the pure Rust code coming from the bdk library and the final language bindings in Swift, Kotlin, and Python.
68

79
With wrapping comes (a) the requirement for naming potentially new types, and (b) the ability to "wrap" behaviour that could be useful for end users. This document addresses point (a).
810

911
## Decision Drivers
12+
1013
Our main goals are:
1114
1. Keep the multiple language bindings libraries maintainable.
12-
2. Help user of bdk help each other and working with a similarly shaped API across languages.
15+
2. Help users of bdk help each other and working with a similarly shaped API across languages.
1316

1417
## Decision Outcome
18+
1519
We decided to try and keep the names of all types the same between the Rust libraries and the bindings, and in cases where new types had to be created, to keep them in the style and spirit of the bdk and rust-bitcoin libraries.
1620

1721
There is so far one exception to this rule, where we renamed the `ScriptBuf` type from rust-bitcoin to `Script`. This was done because the concept of owned vs. borrowed types is strictly a Rust concept, and is not passed onto the languages bindings in any way, and therefore keeping the script type as `Script` was our preferred option in this case.

docs/adr/02-wrapping.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
# Wrapping BDK APIs
2+
23
Producing language bindings potentially requires wrapping a number of APIs, and this document outlines the approach we have decided to take when thinking through this problem for bdk-ffi libraries.
34

45
## Context and Problem Statement
6+
57
The tool we use to produce language bindings for bdk-ffi libraries is [uniffi]. While the library is powerful, it also comes with some caveats. Some of those include the inability to expose to foreign bindings Rust-specific types like tuples, and the inability to expose generics. This means that at least _some_ wrapping and transforming of certain things are required between the pure Rust code coming from the bdk library and the final language bindings in Swift, Kotlin, and Python.
68

79
With wrapping comes (a) the requirement for naming potentially new types, and (b) the ability to "wrap" behaviour that could be useful for end users. This document addresses point (b).
810

911
## Decision Drivers
12+
1013
Our main goals are:
1114
1. Keep the multiple language bindings libraries maintainable.
12-
2. Help user of bdk help each other and working with a similarly shaped API across languages.
15+
2. Help users of bdk help each other and working with a similarly shaped API across languages.
1316

1417
## Decision Outcome
18+
1519
There are three potential reasons for wrapping Rust BDK APIs:
1620
1. The Rust types are not available in the target language (e.g., a function returns a tuple, which can't be returned in Swift/Kotlin)
1721
2. Some complex functionality is available in the Rust bitcoin/miniscript/bdk ecosystem, but exposing all underlying types required for this functionality is out of scope at the time a particular feature is required

docs/adr/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
11
# Architectural Decision Records
2-
This directory contains a series of Architectural Decision Records or "ADRs" for the uniffi project. We're going to try to use it as a kind of collective memory of the decisions we've made and the path we've taken to get the project to its current point.
2+
3+
This directory contains a series of Architectural Decision Records or "ADRs" for the bdk-ffi project. We're going to use it as a kind of collective memory of the decisions we've made and the path we've taken to get the project to its current point.
4+
5+
A good example of simple and well executed ADRs can be found on the [uniffi](https://github.com/mozilla/uniffi-rs/) project repository. See their [readme](https://github.com/mozilla/uniffi-rs/tree/main/docs/adr) and [template](https://github.com/mozilla/uniffi-rs/blob/main/docs/adr/template.md) for more information.
6+
7+
Some more readings on ADRs:
8+
- https://www.ozimmer.ch/practices/2023/04/03/ADRCreation.html
9+
- https://github.com/joelparkerhenderson/architecture-decision-record
10+
- https://adr.github.io/
11+
- https://betterprogramming.pub/the-ultimate-guide-to-architectural-decision-records-6d74fd3850ee
12+
- https://www.redhat.com/architect/architecture-decision-records

0 commit comments

Comments
 (0)