AvroPrism

dev.constructive.eo.avro.AvroPrism
See theAvroPrism companion class
object AvroPrism

Attributes

Companion
class
Source
AvroPrism.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
AvroPrism.type

Members list

Value members

Concrete methods

def codecPrism[S](using codec: AvroCodec[S]): AvroPrism[S]

Root AvroPrism[S], summoning the schema from the codec (AvroCodec[S].schema). The reader schema always matches the codec's — there is no explicit-schema overload, since a reader schema diverging from its codec is a footgun (silent misreads on structural drift).

Root AvroPrism[S], summoning the schema from the codec (AvroCodec[S].schema). The reader schema always matches the codec's — there is no explicit-schema overload, since a reader schema diverging from its codec is a footgun (silent misreads on structural drift).

Attributes

Source
AvroPrism.scala

Extensions

Extensions

extension [A](o: AvroPrism[A])
transparent inline def field[B](inline selector: A => B)(using codecB: AvroCodec[B]): AvroPrism[B]

.field(_.x) — drill via selector lambda.

.field(_.x) — drill via selector lambda.

Attributes

Source
AvroPrism.scala
extension [A](o: AvroPrism[A])
def fieldNamed[B](schemaName: String)(using codecB: AvroCodec[B]): AvroPrism[B]

.fieldNamed[B]("schema_name") — drill by the EXPLICIT schema field name, bypassing resolution entirely. The escape hatch for a hand-written codec the resolver cannot read (a field list that both renames beyond recognition and reorders, a column bearing another field's name, two columns normalising alike); the common (derived / order-preserving / name-transformed) codecs need .field(_.x) instead, which resolves the name for you.

.fieldNamed[B]("schema_name") — drill by the EXPLICIT schema field name, bypassing resolution entirely. The escape hatch for a hand-written codec the resolver cannot read (a field list that both renames beyond recognition and reorders, a column bearing another field's name, two columns normalising alike); the common (derived / order-preserving / name-transformed) codecs need .field(_.x) instead, which resolves the name for you.

The name is CHECKED against the schema it will be looked up in, at construction (issue #95): a name the record does not carry throws rather than Missing silently at runtime. A MAP parent is carved out — .fieldNamed is also how a map KEY is addressed, and an absent key is data, not a mistake. To feature-detect a RECORD field, ask the schema: codec.schema.getField(name).

Attributes

Source
AvroPrism.scala
extension [A](o: AvroPrism[A])
transparent inline def at(i: Int): Any

.at(i) — drill into the i-th array element / map entry.

.at(i) — drill into the i-th array element / map entry.

Attributes

Source
AvroPrism.scala
extension [A](o: AvroPrism[A])
transparent inline def union[Branch]: Any

.union[Branch] — drill into a union alternative by branch type.

.union[Branch] — drill into a union alternative by branch type.

Attributes

Source
AvroPrism.scala
extension [A](o: AvroPrism[A])
transparent inline def each: Any

.each — split into an AvroTraversal over the iterated array.

.each — split into an AvroTraversal over the iterated array.

Attributes

Source
AvroPrism.scala
extension [A](o: AvroPrism[A])
transparent inline def fields(inline selectors: A => Any*): Any

.fields(_.a, _.b, ...) — focus a NamedTuple over selected fields.

.fields(_.a, _.b, ...) — focus a NamedTuple over selected fields.

The AvroCodec for the synthesised NamedTuple is summoned at the call site; with no hand-written given in scope it auto-derives through kindlings. That works for '''2 to 22''' selectors. At 23 or more, Scala has no TupleN spelling left — the focus type IS a *: cons chain — and kindlings 0.3.0 / hearth 0.4.0 cannot construct one, so the call fails to compile with too many arguments for constructor *:. Chain two .fields covers, or drill with .field, until the dependency moves to hearth ≥ 0.4.2. (Issue #96.)

Attributes

Source
AvroPrism.scala