-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
72 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,15 @@ | ||
defmodule Protox.Scalar do | ||
@moduledoc false | ||
|
||
@typedoc """ | ||
All the possible types that can be used as a default value for a scalar. | ||
""" | ||
@type scalar_default_value_type :: | ||
binary() | ||
| boolean() | ||
| integer() | ||
| float() | ||
| atom() | ||
| nil | ||
|
||
@type t() :: %__MODULE__{ | ||
default_value: scalar_default_value_type() | ||
} | ||
|
||
@enforce_keys [:default_value] | ||
defstruct [:default_value] | ||
end | ||
|
||
defmodule Protox.OneOf do | ||
@moduledoc false | ||
|
||
@type t() :: %__MODULE__{ | ||
parent: atom() | ||
} | ||
|
||
@enforce_keys [:parent] | ||
defstruct [:parent] | ||
end | ||
|
||
defmodule Protox.Kind do | ||
@moduledoc false | ||
@moduledoc """ | ||
Defines the kind of a field. | ||
It can be one of the following: | ||
@typedoc """ | ||
This type indicates how a field is encoded. | ||
- `Protox.Scalar` - A [scalar](https://protobuf.dev/programming-guides/proto3/#scalar) value. | ||
- `:packed` - A [packed repeated](https://protobuf.dev/programming-guides/encoding/#packed) field. | ||
- `:unpacked` - An [unpacked repeated](https://protobuf.dev/programming-guides/encoding/#optional) field. | ||
- `:map` - A [map](https://protobuf.dev/programming-guides/encoding/#maps) field. | ||
- `Protox.OneOf` - A [oneof](https://protobuf.dev/programming-guides/encoding/#oneofs) field. | ||
""" | ||
|
||
@type t() :: Protox.Scalar.t() | :packed | :unpacked | :map | Protox.OneOf.t() | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
defmodule Protox.OneOf do | ||
@moduledoc """ | ||
Represents a [oneof field](https://protobuf.dev/programming-guides/proto3/#oneof) in protobuf. | ||
A oneof field represents a group of fields where only one of them can be set at a time. | ||
This module provides a struct to store the parent field of this oneof group, that is, the | ||
field that effectively contains the set value. | ||
## Fields | ||
* `:parent` - The name the parent field of this oneof group. | ||
""" | ||
|
||
@type t() :: %__MODULE__{ | ||
parent: atom() | ||
} | ||
|
||
@enforce_keys [:parent] | ||
defstruct [:parent] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
defmodule Protox.Scalar do | ||
@moduledoc """ | ||
Represents a scalar field in a Protocol Buffer message. | ||
This module defines a struct that holds information about a scalar field, | ||
particularly its default value. Scalar fields are the basic data types | ||
such as integers, floats, booleans, strings. | ||
The default value is used when a field is not present in the encoded message. | ||
""" | ||
|
||
@typedoc """ | ||
All the possible types that can be used as a default value for a scalar. | ||
""" | ||
@type scalar_default_value_type :: | ||
binary() | ||
| boolean() | ||
| integer() | ||
| float() | ||
| atom() | ||
| nil | ||
|
||
@type t() :: %__MODULE__{ | ||
default_value: scalar_default_value_type() | ||
} | ||
|
||
@enforce_keys [:default_value] | ||
defstruct [:default_value] | ||
end |