Typed descriptor for a single URL path segment. Subtypes include Literal, Int, String, Combined (intra-segment composition via ~), and Trailing (captures remaining path).
Combine representation first, then transform: ~ composes only physical SegmentCodec structure, while transform / transformOrFail lift the segment into a PathCodec (making ~ unavailable afterwards — a transformed wire codec is a domain value, not intra-segment structure).
Attributes
- Companion
- object
- Source
- SegmentCodec.scala
- Graph
-
- Supertypes
- Known subtypes
- Self type
-
SegmentCodec[A]
Members list
Type members
Types
Phantom capture marker: SegmentCodec.NoPathVars when this segment captures nothing (empty and literal segments), SegmentCodec.HasPathVars when it captures a value (bool, int, long, string, UUID, trailing, and any composition containing one of those). This is a second, parallel type track: it never affects A (the runtime-decoded value type) and has zero runtime footprint. Its only consumer is PathCodec.orElse, which requires both branches to be NoPathVars so a capturing codec mapped to Unit is rejected at the call site instead of failing expand at runtime.
Phantom capture marker: SegmentCodec.NoPathVars when this segment captures nothing (empty and literal segments), SegmentCodec.HasPathVars when it captures a value (bool, int, long, string, UUID, trailing, and any composition containing one of those). This is a second, parallel type track: it never affects A (the runtime-decoded value type) and has zero runtime footprint. Its only consumer is PathCodec.orElse, which requires both branches to be NoPathVars so a capturing codec mapped to Unit is rejected at the call site instead of failing expand at runtime.
Attributes
- Source
- SegmentCodec.scala
Value members
Concrete methods
Attributes
- Source
- SegmentCodec.scala
Attributes
- Source
- SegmentCodec.scala
Maps the decoded segment value into a domain type, lifting into a PathCodec.
Maps the decoded segment value into a domain type, lifting into a PathCodec.
Example: SegmentCodec.string("id").transform(CustomerId(_), _.value)
Value parameters
- decode
-
maps the decoded segment value into the exposed type
- encode
-
maps the exposed type back into the original segment representation used by
format
Attributes
- Returns
-
a path codec with the transformed value type and the same route shape as
self - Source
- SegmentCodec.scala
Effectfully maps the decoded segment value into a domain type, lifting into a PathCodec. decode returning Left causes path decoding / matching to fail; encode returning Left is propagated as the Left result of format.
Effectfully maps the decoded segment value into a domain type, lifting into a PathCodec. decode returning Left causes path decoding / matching to fail; encode returning Left is propagated as the Left result of format.
Example: SegmentCodec.string("id").transformOrFail(CustomerId.parse, id => Right(id.value))
Attributes
- Source
- SegmentCodec.scala
Composes two physical segments into one (for example int("n") ~ literal("-") ~ string("rest")).
Composes two physical segments into one (for example int("n") ~ literal("-") ~ string("rest")).
Adjacent string ~ string, numeric ~ numeric (Int/Long in any order, including through a flattened combined tail), and anything involving Trailing are rejected at runtime with IllegalArgumentException (ambiguous splits); put a literal, bool, or UUID segment between them.
The result's PathVars is the logical OR of both sides (computed by the pathVarsCombiner implicit, which defaults conservatively to HasPathVars when either side's marker is unknown), so orElse keeps rejecting compositions that capture.
Attributes
- Source
- SegmentCodec.scala
Composes a physical segment with a literal suffix (for example string("word") ~ "!"). The literal is validated exactly like SegmentCodec.literal (empty, /-carrying, or encoding-requiring values are rejected with IllegalArgumentException).
Composes a physical segment with a literal suffix (for example string("word") ~ "!"). The literal is validated exactly like SegmentCodec.literal (empty, /-carrying, or encoding-requiring values are rejected with IllegalArgumentException).
Attributes
- Source
- SegmentCodec.scala