Skip to content

Commit

Permalink
docs: fidl default value, fidl oneof
Browse files Browse the repository at this point in the history
  • Loading branch information
veith committed Dec 28, 2021
1 parent f0e1548 commit 401d5b8
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 27 deletions.
4 changes: 2 additions & 2 deletions docs/fidl/content/_index.md
Expand Up @@ -41,8 +41,8 @@ There is a short notation form [(µSpecs)](/docs/µSpecs/) and the standard nota
cid: 'string #The query param cid stands for client id.'
```
- look at some example projects
- read the [overview]()
- install the [tools]()
- read the [overview](/docs/overview/)


{{< /columns >}}

Expand Down
15 changes: 11 additions & 4 deletions docs/fidl/content/docs/overview/oneof.md
Expand Up @@ -10,14 +10,19 @@ In the client lib, at most one field can be set at the same time.
Setting any member of the oneof automatically clears all the other members.


{{< hint warning >}}
The oneof feature is **not** available **µSpec**. You have to specify them in the spec.
{{< /hint >}}


## Using Oneof
Just define a name for the oneof.

*field section of a type µSpec*
```yaml
fields:
method: '* string:1 [handler] #The name of the method to call with the wire data. If you want add custom code use source instead of method. /oneof:handler/'
source: '* string:2 [handler] #Anonyous method to handle the wire. Prefer the use of method. /oneof:handler/'

```

*field section of a type spec*
```yaml
fields:
method:
Expand Down Expand Up @@ -60,6 +65,8 @@ fields:
```

The resulting proto would be like:

*proto*
```proto
// Wire hooks to connect internal wires with methods.
Expand Down
3 changes: 0 additions & 3 deletions docs/fidl/content/docs/overview/streaming/_index.md
Expand Up @@ -12,9 +12,6 @@ bookCollapseSection: true

You can do streaming by adding the keyword **stream** to your response type.

{{< hint info >}}
Streaming is only supported as response type (Server streaming RPC or in simle words: from server to the client) at the moment.
{{< /hint >}}

{{< hint warning >}}
You need at least [**furo 1.24.1**](https://furo.pro/) to use this feature
Expand Down
53 changes: 37 additions & 16 deletions docs/fidl/content/docs/µSpecs/types.md
Expand Up @@ -34,10 +34,10 @@ You can have as many type definitions per file as you want. It makes sense that

```yaml
- type: 'sample.Sample #A sample type'
!___! !___________! !____________!
| | |
| type name |
| |
!___! !____||_____! !____________!
| | | |
| | type name |
| package |
| description (recomended) begins with a #
|
|
Expand All @@ -46,17 +46,14 @@ field name of the type


```
### type name
is defined by package.Type


### description
It is a good practice to give a good description of the type. This description will go to the generated protos and other generates.
It is a good practice to give a good description of the type.

## Fields

In the "fields-object", what a surprise, you define the fields / attributes of a type.

*minimalistic example*
```yaml
fieldname: '* string:2 #The description.'
!_______! !_!!____!!_!!________________!
Expand All @@ -71,24 +68,48 @@ fieldname: '* string:2 #The description.'

```

### fieldname
*example with default value and oneof*
```yaml
fieldname: '* string:2 = default value [oneofname] #The description.'
!_______! !_!!____!!_!!______________!!__________!!________________!
| | | | | | |
| | | | | oneof definition in [] |
| | | | default value (=) |
| | | | |
| | | | description (recomended) begins with a #
field name | | |
| | field id, indicated by a :
| |
| type
|
Indicator for required (*), readonly (-), repeated ([])

```

### Fieldname
The name of the field

### indicator required
### Indicator for required
If the field is required, type in a *

### indicator readonly
### Indicator for readonly
If the field is readonly, type in a -

### indicator repeated
### Indicator for repeated
If the field is repeated, type in a []

### type
### Type
Types are the same like in protobuf

### field id
### Field id
The field id must be unique, the generated protos use them too

### description
### Default value
This does not reflect in the protos.

### Oneof definition


### Description
It is a good practice to give a good description of the type. This description will go to the generated protos and other generates.

Large diffs are not rendered by default.

@@ -1 +1 @@
{"Target":"book.min.966d8ceb5ee6376c5ee67e63a985eab55f0bf8c16f7bc27fbd4069e2254956a9.css","MediaType":"text/css","Data":{"Integrity":"sha256-lm2M617mN2xe5n5jqYXqtV8L+MFve8J/vUBp4iVJVqk="}}
{"Target":"book.min.d917efb76f69f2afa7b6886371b327a3f18051eaa11d48b3ffe6a21842c74412.css","MediaType":"text/css","Data":{"Integrity":"sha256-2Rfvt29p8q+ntohjcbMno/GAUeqhHUiz/+aiGELHRBI="}}

0 comments on commit 401d5b8

Please sign in to comment.