SegmentCodec

zio.blocks.endpoint.SegmentCodec
See theSegmentCodec companion trait
object SegmentCodec

Attributes

Companion
trait
Source
SegmentCodec.scala
Graph
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type

Members list

Type members

Classlikes

final case class BoolSeg[N <: String](name: N, doc: Doc = ..., examples: Chunk[(String, Boolean)] = ...) extends SegmentCodec[Boolean]

Attributes

Source
SegmentCodec.scala
Supertypes
trait Serializable
trait Product
trait Equals
trait SegmentCodec[Boolean]
class Object
trait Matchable
class Any
Show all

Attributes

Companion
trait
Source
SegmentCodec.scala
Supertypes
class Object
trait Matchable
class Any
Self type
sealed trait CombinePathVars[L, R, Out]

Compile-time evidence combining two PathVars markers into their logical OR, driving PVC inference for ~ (and, transitively, PathCodec.++ and /). The four precise instances cover every concrete pair; the low-priority fallback maps anything unknown (an unrefined codec type, whose marker is abstract) to HasPathVars - always sound (capturing is the safe over-approximation: orElse may reject a harmless unrefined codec, but it can never accept a capturing one through this path).

Compile-time evidence combining two PathVars markers into their logical OR, driving PVC inference for ~ (and, transitively, PathCodec.++ and /). The four precise instances cover every concrete pair; the low-priority fallback maps anything unknown (an unrefined codec type, whose marker is abstract) to HasPathVars - always sound (capturing is the safe over-approximation: orElse may reject a harmless unrefined codec, but it can never accept a capturing one through this path).

Attributes

Companion
object
Source
SegmentCodec.scala
Supertypes
class Object
trait Matchable
class Any

Attributes

Source
SegmentCodec.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
final case class Combined[A, B, C](left: SegmentCodec[A], right: SegmentCodec[B], combiner: WithOut[A, B, C]) extends SegmentCodec[C]

Attributes

Source
SegmentCodec.scala
Supertypes
trait Serializable
trait Product
trait Equals
trait SegmentCodec[C]
class Object
trait Matchable
class Any
Show all
case object Empty extends SegmentCodec[Unit]

Attributes

Source
SegmentCodec.scala
Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait SegmentCodec[Unit]
class Object
trait Matchable
class Any
Show all
Self type
Empty.type
sealed trait HasPathVars

Phantom marker for segments that capture a value (bool, int, long, string, UUID, trailing, and any composition containing one of those). Never instantiated - exists purely as a PathVars tag with zero runtime footprint.

Phantom marker for segments that capture a value (bool, int, long, string, UUID, trailing, and any composition containing one of those). Never instantiated - exists purely as a PathVars tag with zero runtime footprint.

Attributes

Source
SegmentCodec.scala
Supertypes
class Object
trait Matchable
class Any
final case class IntSeg[N <: String](name: N, doc: Doc = ..., examples: Chunk[(String, Int)] = ...) extends SegmentCodec[Int]

Attributes

Source
SegmentCodec.scala
Supertypes
trait Serializable
trait Product
trait Equals
trait SegmentCodec[Int]
class Object
trait Matchable
class Any
Show all
object Key

Attributes

Companion
trait
Source
SegmentCodec.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Key.type
sealed trait Key

Attributes

Companion
object
Source
SegmentCodec.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Bool
class Combined
object Empty
object Int
class Literal
object Long
object String
object Trailing
object UUID
Show all
object Kind

Attributes

Companion
trait
Source
SegmentCodec.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Kind.type
sealed trait Kind

Attributes

Companion
object
Source
SegmentCodec.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Bool
object Combined
object Empty
object Int
object Literal
object Long
object String
object Trailing
object UUID
Show all
final case class Literal(value: String, doc: Doc = ..., examples: Chunk[(String, Unit)] = ...) extends SegmentCodec[Unit]

Attributes

Source
SegmentCodec.scala
Supertypes
trait Serializable
trait Product
trait Equals
trait SegmentCodec[Unit]
class Object
trait Matchable
class Any
Show all
final case class LongSeg[N <: String](name: N, doc: Doc = ..., examples: Chunk[(String, Long)] = ...) extends SegmentCodec[Long]

Attributes

Source
SegmentCodec.scala
Supertypes
trait Serializable
trait Product
trait Equals
trait SegmentCodec[Long]
class Object
trait Matchable
class Any
Show all
sealed trait NoPathVars

Phantom marker for segments that capture nothing (Empty, Literal). Never instantiated - exists purely as a PathVars tag with zero runtime footprint.

Phantom marker for segments that capture nothing (Empty, Literal). Never instantiated - exists purely as a PathVars tag with zero runtime footprint.

Attributes

Source
SegmentCodec.scala
Supertypes
class Object
trait Matchable
class Any
final case class StringSeg[N <: String](name: N, doc: Doc = ..., examples: Chunk[(String, String)] = ...) extends SegmentCodec[String]

Attributes

Source
SegmentCodec.scala
Supertypes
trait Serializable
trait Product
trait Equals
trait SegmentCodec[String]
class Object
trait Matchable
class Any
Show all
case object Trailing extends SegmentCodec[Path]

Attributes

Source
SegmentCodec.scala
Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type
Trailing.type
final case class UUIDSeg[N <: String](name: N, doc: Doc = ..., examples: Chunk[(String, UUID)] = ...) extends SegmentCodec[UUID]

Attributes

Source
SegmentCodec.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Inherited and Abstract types

type MirroredElemLabels <: Tuple

The names of the product elements.

The names of the product elements.

Attributes

Inherited from:
Mirror
Source
Mirror.scala
type MirroredLabel <: String

The name of the type.

The name of the type.

Attributes

Inherited from:
Mirror
Source
Mirror.scala

Value members

Concrete methods

def decodeCombined(codec: SegmentCodec[_], segment: String, from: Int): List[(Any, Int)]

Attributes

Source
SegmentCodec.scala
def decodeComplete(codec: SegmentCodec[_], segment: String): List[(Any, Int)]

Value-carrying counterpart to matchesComplete: the full-length survivors of decodeCombined(codec, segment, 0) (candidates whose end equals segment.length), longest split first. StringSeg materializes one substring per surviving split only — the decoded String value IS a substring, so that allocation is the result, not a parse intermediate. Used by PathCodecRuntime.decodeSegment for Combined segments.

Value-carrying counterpart to matchesComplete: the full-length survivors of decodeCombined(codec, segment, 0) (candidates whose end equals segment.length), longest split first. StringSeg materializes one substring per surviving split only — the decoded String value IS a substring, so that allocation is the result, not a parse intermediate. Used by PathCodecRuntime.decodeSegment for Combined segments.

Attributes

Source
SegmentCodec.scala
def flatten(codec: SegmentCodec[_]): Chunk[SegmentCodec[_]]

Attributes

Source
SegmentCodec.scala
def formatSegment(codec: SegmentCodec[_], value: Any): String

Attributes

Source
SegmentCodec.scala
def matches(codec: SegmentCodec[_], segments: Chunk[String], index: Int): Int

Returns how many segments codec consumes at index (-1 for no match).

Returns how many segments codec consumes at index (-1 for no match).

This is the boolean fast path for routing: Literal is a single ==, IntSeg/LongSeg allocation-free ASCII window scans (isIntWindow/isLongWindow), UUIDSeg a hand-rolled shape check (no exceptions thrown), and Combined goes through the exhaustive-split matchesWindow below. Candidate lists are never built here (unlike decodeCombined), so per-request trie lookups pay no per-candidate tuple or substring-enumeration cost. The subsequent handler decode re-parses the matched segment once — that match-then-decode double parse is accepted deliberately (decode happens once per matched request, while matches runs per dynamic branch).

Attributes

Source
SegmentCodec.scala
def matchesComplete(codec: SegmentCodec[_], segment: String): Boolean

Boolean counterpart to decodeComplete: does codec match segment exactly? Never builds candidate lists and never allocates — StringSeg is a constant-time accept, numerics validate each candidate window with the allocation-free ASCII scanners (no substring), UUIDSeg is validated index-by-index without exceptions, and Combined enumerates candidate split points with the same accept/reject predicate decodeCombined uses — so matches and decode agree structurally (one existential, one constructive, over the same split language). Used by matches and PathCodecRuntime.matchesCodec.

Boolean counterpart to decodeComplete: does codec match segment exactly? Never builds candidate lists and never allocates — StringSeg is a constant-time accept, numerics validate each candidate window with the allocation-free ASCII scanners (no substring), UUIDSeg is validated index-by-index without exceptions, and Combined enumerates candidate split points with the same accept/reject predicate decodeCombined uses — so matches and decode agree structurally (one existential, one constructive, over the same split language). Used by matches and PathCodecRuntime.matchesCodec.

Attributes

Source
SegmentCodec.scala
def render(codec: SegmentCodec[_], prefix: String = ..., suffix: String = ...): String

Attributes

Source
SegmentCodec.scala

Inherited methods

def bool[N <: String & Singleton](name: N): BoolSeg[N]

Attributes

Inherited from:
SegmentCodecPlatformSpecific (hidden)
Source
SegmentCodecPlatformSpecific.scala
def int[N <: String & Singleton](name: N): IntSeg[N]

Attributes

Inherited from:
SegmentCodecPlatformSpecific (hidden)
Source
SegmentCodecPlatformSpecific.scala
inline def literal(inline value: String): Literal

Attributes

Inherited from:
SegmentCodecPlatformSpecific (hidden)
Source
SegmentCodecPlatformSpecific.scala
def long[N <: String & Singleton](name: N): LongSeg[N]

Attributes

Inherited from:
SegmentCodecPlatformSpecific (hidden)
Source
SegmentCodecPlatformSpecific.scala
def string[N <: String & Singleton](name: N): StringSeg[N]

Attributes

Inherited from:
SegmentCodecPlatformSpecific (hidden)
Source
SegmentCodecPlatformSpecific.scala
def uuid[N <: String & Singleton](name: N): UUIDSeg[N]

Attributes

Inherited from:
SegmentCodecPlatformSpecific (hidden)
Source
SegmentCodecPlatformSpecific.scala

Implicits

Implicits

implicit val keyOrdering: Ordering[Key]

Attributes

Source
SegmentCodec.scala
implicit val segmentCodecOrdering: Ordering[Kind]

Attributes

Source
SegmentCodec.scala