Skip to content

Commit

Permalink
Add information about request timeout to the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
temeddix committed Nov 2, 2023
1 parent 8c93865 commit 54ae2f2
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions documentation/docs/writing-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,25 +271,30 @@ children: [

We rebuild the widget with the received data here, but the streamed data can also be used to update Dart states in real apps.

## 🏷️ Meanings of Each Field
## 🏷️ Message Details

We've seen how to pass `RustRequest`, `RustResponse`, and `RustSignal` between Dart and Rust in this tutorial. Now let's go over to what exactly each field means.
### Meanings of Each Field

### Field `resource`
We've seen how to pass `RustRequest`, `RustResponse`, and `RustSignal` between Dart and Rust in this tutorial. Now let's go over to what exactly each field means.

This is an integer pointing to a virtual Rust resource that suits your app's design. Always provide `ID` of some message module generated by `rinf message`.
- Field `resource`: This is an integer pointing to a virtual Rust resource that suits your app's design. Always provide `ID` of some message module generated by `rinf message`.

### Field `operation`
- Field `operation`: This accepts an enum value of `RustOperation` and can be one of create, read, update, and delete, since this system follows the definition of RESTful API.

This accepts an enum value of `RustOperation` and can be one of create, read, update, and delete, since this system follows the definition of RESTful API.
- Field `message`: This is a bytes array created by Protobuf serialization. Note that it is not recommended to create Protobuf messages that are bigger than a few megabytes. To send large data, use `blob` instead. Sending bytes array is a zero-copy operation, though Protobuf serialization and deserialization process does involve memory copy. This field is optional and can be `null` or `None`.

### Field `message`
- Field `blob`: This is also a bytes array intended to contain large data, possibly up to a few gigabytes. You can send any kind of binary as you wish such as a high-resolution image or some kind of file data. Sending a blob from Rust to Dart is a zero-copy operation, meaning there's no memory copy involved. In contrast, sending a blob from Dart to Rust is a copy operation. This field is optional and can be `null` or `None`.

This is a bytes array created by Protobuf serialization. Note that it is not recommended to create Protobuf messages that are bigger than a few megabytes. To send large data, use `blob` instead. Sending bytes array is a zero-copy operation, though Protobuf serialization and deserialization process does involve memory copy. This field is optional and can be `null` or `None`.
### Response Timeout

### Field `blob`
By default, Dart will receive a failed `RustResponse` if Rust doesn't respond within 60 seconds. To set a custom timeout for your `RustRequest`, you can optionally provide a timeout argument to the `requestToRust` function like this:

This is also a bytes array intended to contain large data up to a few gigabytes. You can send any kind of binary as you wish such as a high-resolution image or some kind of file data. Sending a blob is a zero-copy operation, which means no memory copy is involved. This field is optional and can be `null` or `None`.
```dart
final rustResponse = await requestToRust(
rustRequest,
timeout: const Duration(minutes: 5),
);
```

## 🖨️ The `debug_print!` Macro

Expand Down

0 comments on commit 54ae2f2

Please sign in to comment.