When applied on raw method, it works almost the same way as single except that it is not required that
matching real method exists in real RPC trait. If there is no matching real method, macro-materialized AsRaw
implementation will implement the raw method with a code that throws an exception.
When applied on raw parameter, specifies that this raw parameter may be matched by a real parameter but this is
not required. Whether a real parameter matches an optional raw parameter is determined by its type and/or tag
(see paramTag for more information on param tagging).
Raw parameters marked as optional must be typed as Option[T] (or Opt[T], OptArg[T] or whatever type that
has an instance of OptionLike). By default, optional raw parameters are verbatim which means that the
option-wrapped type T must match exactly the type of real parameter.
In the macro generated code that translates a raw call into a real call, when the raw parameter value is absent
(the Option[T] is empty) then real parameter's default value will be used as fallback. This allows introducing
new parameters into RPC interfaces without breaking backwards compatibility.
optional may also be used on method metadata parameters or parameter metadata parameters. It works the same
way as with single except that metadata class must be wrapped in an OptionLike type (Option, Opt, etc.).
Finally, optional may also be used for metadata parameters that hold reified annotations (see reifyAnnot).
In that case it is not required that the annotation being reified is actually present on the real trait/method/param.
For that to work, metadata param must be typed as Option[A], Opt[A], etc. where A is the type of annotation
being reified.
When applied on raw method, it works almost the same way as single except that it is not required that matching real method exists in real RPC trait. If there is no matching real method, macro-materialized
AsRaw
implementation will implement the raw method with a code that throws an exception.When applied on raw parameter, specifies that this raw parameter may be matched by a real parameter but this is not required. Whether a real parameter matches an optional raw parameter is determined by its type and/or tag (see paramTag for more information on param tagging).
Raw parameters marked as optional must be typed as
Option[T]
(orOpt[T]
,OptArg[T]
or whatever type that has an instance ofOptionLike
). By default, optional raw parameters are verbatim which means that the option-wrapped typeT
must match exactly the type of real parameter.In the macro generated code that translates a raw call into a real call, when the raw parameter value is absent (the
Option[T]
is empty) then real parameter's default value will be used as fallback. This allows introducing new parameters into RPC interfaces without breaking backwards compatibility.optional may also be used on method metadata parameters or parameter metadata parameters. It works the same way as with single except that metadata class must be wrapped in an
OptionLike
type (Option
,Opt
, etc.).Finally, optional may also be used for metadata parameters that hold reified annotations (see reifyAnnot). In that case it is not required that the annotation being reified is actually present on the real trait/method/param. For that to work, metadata param must be typed as
Option[A]
,Opt[A]
, etc. whereA
is the type of annotation being reified.