@ @explicit
@explicit
Applies to: interface
Section: §4.6
Syntax
Attr = "@" Path [ "(" [ AttrArgs ] ")" ] ;Grammar: App. A
Defined in
- 4.6 Interfaces — Interfaces are structural
- 4.9 Attributes — Syntax: @name or @name(arguments) before a declaration, field, parameter or rpc.
- 9.5 User-defined serialisers — Level 1 — representation through another type (Repr), acts in all formats and in schemas
- 10.2 rpc attributes — Defaults for all rpcs are set in cluster { defaults { …
Examples
pub(api) interface Storage {
fn get(k: str) -> bytes? io
var fn put(k: str, v: bytes) io
fn has(k: str) -> bool io => get(k) != none // a default method
}
interface ReadWrite { embed Reader; embed Writer }
interface Container<T> { type Item = T; fn items() -> iter<T> }
@explicit interface Persistent { fn key() -> str }
assert FileStorage: Storage // static check@explicit interface Codec<T> {
static fn encode(x: &T, w: &var Encoder) -> () | EncodeError
static fn decode(r: &var Decoder) -> T | DecodeError
static fn schema() -> Schema // for oxl export
}
data Event {
@codec(json: Iso8601) at: Time // in JSON an ISO 8601 string, in binary the default
@codec(Base64Url) token: bytes // in all formats
}
@codec(GeoHashCodec) data Point { lat: f64; lon: f64 }— 9.5 User-defined serialisers
Related diagnostics
explicit-interface, interface-not-satisfied, deprecated, schema-attr, attribute-not-applicable, cache-not-readonly, invalid-window, retry-not-idempotent, rpc-attr