Segment

zio.blocks.endpoint.PathCodec.Segment
final case class Segment[A](segment: SegmentCodec[A]) extends PathCodec[A]

Attributes

Source
PathCodec.scala
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait PathCodec[A]
class Object
trait Matchable
class Any
Show all

Members list

Type members

Types

type PathVars

Phantom capture marker: SegmentCodec.NoPathVars when this path captures nothing (empty paths, literal-only paths), SegmentCodec.HasPathVars when any segment captures a value. Never affects A (the runtime-decoded value type), zero runtime footprint. Threaded through ++, /, SegmentCodec.~, and transform so orElse can reject capturing branches at the call site.

Phantom capture marker: SegmentCodec.NoPathVars when this path captures nothing (empty paths, literal-only paths), SegmentCodec.HasPathVars when any segment captures a value. Never affects A (the runtime-decoded value type), zero runtime footprint. Threaded through ++, /, SegmentCodec.~, and transform so orElse can reject capturing branches at the call site.

Attributes

Source
PathCodec.scala

Value members

Inherited methods

final def ++[B, C, PV2, PVC](that: PathCodec[B] { type PathVars = PV2; })(implicit combiner: WithOut[A, B, C], pathVarsCombiner: CombinePathVars[PathVars, PV2, PVC]): PathCodec[C] { type PathVars = PVC; }

Concatenates two path codecs, combining decoded values with Tuples.Tuples.WithOut (so Int / String decodes to (Int, String)). The result's PathVars is the logical OR of both sides (unknown markers default to capturing - see SegmentCodec.CombinePathVars).

Concatenates two path codecs, combining decoded values with Tuples.Tuples.WithOut (so Int / String decodes to (Int, String)). The result's PathVars is the logical OR of both sides (unknown markers default to capturing - see SegmentCodec.CombinePathVars).

Attributes

Inherited from:
PathCodec
Source
PathCodec.scala
final def /[B, C, PV2, PVC](that: PathCodec[B] { type PathVars = PV2; })(implicit combiner: WithOut[A, B, C], pathVarsCombiner: CombinePathVars[PathVars, PV2, PVC]): PathCodec[C] { type PathVars = PVC; }

Symbolic alias for ++ — PathCodec.int("id") / PathCodec.string("slug").

Symbolic alias for ++ — PathCodec.int("id") / PathCodec.string("slug").

Attributes

Inherited from:
PathCodec
Source
PathCodec.scala
final def alternatives: List[PathCodec[A]]

Attributes

Inherited from:
PathCodec
Source
PathCodec.scala
final def decode(path: Path): Either[String, A]

Decodes path, naming the furthest segment reached on failure (for example failed at segment 1 ('abc')). The position is message-level context only — errors stay Either[String, A]; a full Either[SchemaError, A] migration composing positions à la SchemaError.atField/atIndex remains future work.

Decodes path, naming the furthest segment reached on failure (for example failed at segment 1 ('abc')). The position is message-level context only — errors stay Either[String, A]; a full Either[SchemaError, A] migration composing positions à la SchemaError.atField/atIndex remains future work.

Attributes

Inherited from:
PathCodec
Source
PathCodec.scala
final def format(value: A): Either[String, Path]

Attributes

Inherited from:
PathCodec
Source
PathCodec.scala
final def matches(path: Path): Boolean

Boolean fast path: equivalent to decode(path).isRight without building any decoded values or candidate lists (see PathCodecRuntime.matchesCodec).

Boolean fast path: equivalent to decode(path).isRight without building any decoded values or candidate lists (see PathCodecRuntime.matchesCodec).

Attributes

Inherited from:
PathCodec
Source
PathCodec.scala
final def orElse(that: PathCodec[Unit] { type PathVars = NoPathVars; })(implicit ev: (A, PathVars) =:= (Unit, NoPathVars)): PathCodec[Unit] { type PathVars = NoPathVars; }

Literal-only alternative (users or posts). Both branches must be literal-only: that is required to carry NoPathVars, and the ev evidence requires (A, PathVars) to equal (Unit, NoPathVars) — so a capturing codec mapped to PathCodec[Unit] (for example PathCodec.int("id").transform(_ => (), _ => 0), whose marker stays HasPathVars through transform) is rejected at the call site rather than failing expand at runtime. Non-literal Fallback branches that slip past the types are still validated at runtime by expand.

Literal-only alternative (users or posts). Both branches must be literal-only: that is required to carry NoPathVars, and the ev evidence requires (A, PathVars) to equal (Unit, NoPathVars) — so a capturing codec mapped to PathCodec[Unit] (for example PathCodec.int("id").transform(_ => (), _ => 0), whose marker stays HasPathVars through transform) is rejected at the call site rather than failing expand at runtime. Non-literal Fallback branches that slip past the types are still validated at runtime by expand.

Attributes

Inherited from:
PathCodec
Source
PathCodec.scala
def productElementNames: Iterator[String]

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
Source
Product.scala
def productIterator: Iterator[Any]

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product
Source
Product.scala
final def render: String

Attributes

Inherited from:
PathCodec
Source
PathCodec.scala
final def transform[B, PV](decode: A => B, encode: B => A)(implicit ev: CombinePathVars[PathVars, NoPathVars, PV]): PathCodec[B] { type PathVars = PV; }

Maps the decoded path value without changing the underlying path structure.

Maps the decoded path value without changing the underlying path structure.

Example: {{ val customerPath = PathCodec.int("id").transform(CustomerId(_), _.value) }}

Value parameters

decode

maps the decoded path value into the exposed type

encode

maps the exposed type back into the original path representation used by format

Attributes

Returns

a path codec with the transformed value type and the same route shape as self

Inherited from:
PathCodec
Source
PathCodec.scala
final def transformOrFail[B, PV](decode: A => Either[String, B], encode: B => Either[String, A])(implicit ev: CombinePathVars[PathVars, NoPathVars, PV]): PathCodec[B] { type PathVars = PV; }

Effectfully maps the decoded path value without changing the underlying path structure.

Effectfully maps the decoded path value without changing the underlying path structure.

decode returning Left causes path decoding / matching to fail. format remains effectful, so encode returning Left is propagated as the Left result of format.

Example: {{ val customerPath = PathCodec .string("id") .transformOrFail(CustomerId.parse, value => Right(value.value)) }}

Value parameters

decode

validates and maps the decoded path value into the exposed type

encode

validates and maps the exposed type back into the original path representation used by format

Attributes

Returns

a path codec with the transformed value type and the same route shape as self

Inherited from:
PathCodec
Source
PathCodec.scala
final def unused[PV](implicit ev: CombinePathVars[PathVars, NoPathVars, PV]): PathCodec[Unit] { type PathVars = PV; }

Marks this path's captured value as intentionally unused: the route keeps matching the same shape and keeps rendering the same {name} placeholders, but decoding yields Unit instead of the captured value, so no handler parameter is required for it.

Marks this path's captured value as intentionally unused: the route keeps matching the same shape and keeps rendering the same {name} placeholders, but decoding yields Unit instead of the captured value, so no handler parameter is required for it.

Example: PathCodec.int("id").unused still matches /42 and still renders /{id}, yet the endpoint's path input is Unit.

Like transform, this reifies the marker (identity OR with NoPathVars), so an unused literal-only path stays NoPathVars while an unused capturing path stays HasPathVars. Formatting an unused path fails: there is no value to encode back into the ignored segment.

Attributes

Returns

a path codec with value type Unit and the same route shape as self

Inherited from:
PathCodec
Source
PathCodec.scala