Skip to content

Commit

Permalink
add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
timwu20 committed Jun 23, 2021
1 parent f4e83aa commit 9511f9b
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions pkg/scale/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ SCALE uses a compact encoding for variable width unsigned integers.
| `Compact<u64>` | `uint` |
| `Compact<u128>` | `*big.Int` |

### Result

> TODO: To be implemented and documented.
## Usage

### Basic Example
Expand Down Expand Up @@ -150,6 +146,19 @@ func structExample() {
}
```

### Result

A `Result` is custom type analogous to a rust result. A `Result` needs to be constructed using the `NewResult` constructor. The two parameters accepted are the expected types that are associated to the `Ok`, and `Err` cases.

```
// Rust
Result<i32, i32> = Ok(10)
// go-scale
result := scale.NewResult(int32(0), int32(0)
result.Set(scale.Ok, 10)
```

### Varying Data Type

A `VaryingDataType` is analogous to a Rust enum. A `VaryingDataType` needs to be registered using the `RegisterVaryingDataType` function with its associated `VaryingDataTypeValue` types. `VaryingDataTypeValue` is an
Expand Down

0 comments on commit 9511f9b

Please sign in to comment.