kw pub
Reserved keyword
The list of words: §1.4
Syntax
Vis = "pub" [ "(" "api" ")" ] ;Grammar: App. A
Defined in
- 4.2 data — A field: visibility?
- 4.4 enum — A variant: without fields, with positional or with named fields.
- 2.3 Visibility — The modifier applies to declarations and to the fields of data.
- 4.5 impl and methods — Inside a method self and Self are available.
- 4.6 Interfaces — Interfaces are structural
- 6.2 Effects — The set of effects is written after the return type, comma-separated
- 10.1 Services — A service declares a contract
- 16.3 gRPC and protobuf — import proto "payments.proto" generates an extern service and types; calls are as to ordinary services through connect.
Examples
pub(api) data User {
pub(api) id: UserId
pub(api) name: Name
pub(api) email: Email? @since(2)
role: Role = Role.User
createdAt: Time = now()
invariant name != "admin" || role == Role.Admin
}— 4.2 data
pub(api) enum Role { User, Support, Admin }
pub(api) enum Shape {
Circle(r: f64)
Rect(w: f64, h: f64)
Empty
}
@error enum PayError { Declined(reason: str), Fraud, Limit(max: Money) }
@open pub(api) enum Status { New = 1, Paid = 2, Shipped = 3 }— 4.4 enum
Related diagnostics
unknown-field, private-in-public, visibility, impl-foreign-type, unknown-method, explicit-interface, interface-not-satisfied, effects, duplicate-impl, impl-signature-mismatch, missing-impl, missing-rpc-impl, unknown-rpc, import-skip