# `nupp.serde.adapters` These builders give a model library that owns its schema adapters over its own `nupp.serde.Member` type. See [Serialization bindings](../../../../learn/runtime/data/serde/index.html#model-owned-bindings) for how model bindings fit beside declaration bindings. A declaration binding from `nupp.serde.binding` covers ordinary records. A library that generates types from Smithy, OpenAPI, or a binary schema needs its own member identities instead, so its codec policy can read shape identifiers, XML namespaces, or field numbers off them. ```nupp local serde = require("nupp.serde") local adapters = require("nupp.serde.adapters") local json = require("nupp.serde.json") local plain = json.codec(json.memberNamePolicy) -- The model's own member type. A real library would carry its schema here. local record Member is serde.Member @readonly name: string @readonly index: integer? end local record Book title: string tags: {string} end -- Reading builds a Book through an exclusive draft that is closed either way. local record Draft is nupp.Closeable title: string? tags: {string}? function close(takes self): nil end end local record Construction is adapters.Construction function begin(self): Draft return new Draft() end function finish(self, takes draft: Draft): Book local owned: Draft = draft local book = new Book(title = assert(owned.title, "title is required"), tags = owned.tags or {}) owned:close() return book end end local title = new Member(name = "title") local tags = new Member(name = "tags") local book = adapters.structure(new Member(name = "Book"), { adapters.field( title, function(borrows value: Book): string borrows (value) return value.title end, function(exclusive draft: Draft, value: string): nil draft.title = value end, adapters.text(title), true, false ), adapters.field( tags, function(borrows value: Book): {string} borrows (value) return value.tags end, function(exclusive draft: Draft, value: {string}): nil draft.tags = value end, adapters.list(tags, new Member(name = "tag"), adapters.text(new Member(name = "tag"))), false, true ) }, new Construction()) local books: serde.Binding = new serde.Bound(adapter = book) local bytes = plain:encode(books, new Book(title = "Dune", tags = {"sf"})) assert(bytes == '{"title":"Dune","tags":["sf"]}') assert(plain:decode(books, '{"title":"Emma"}').title == "Emma") ``` Every builder takes the member the value sits at, so the same scalar adapter type serves a top-level value, a structure field, and a list element. Wrap the finished adapter in `nupp.serde.Bound` to pass it to a codec. ## Types ### `BorrowGet` _type_ ```nupp type BorrowGet = function(borrows value: T): V borrows (value) ``` Reads a field by borrowing it from the value. #### Type parameters | Name | Description | | --- | --- | | `T` | | | `V` | | ### `Construction` _interface_ ```nupp interface Construction ... ``` How a [`structure`](#nupp.serde.adapters.structure) opens and finishes the draft its fields are read into. The draft is exclusive and Closeable, so a failed read drops it rather than leaking a half-built value. #### Type parameters | Name | Description | | --- | --- | | `T` | | | `S` | | #### Members | Name | Kind | Description | | --- | --- | --- | | [`begin`](#nupp.serde.adapters.Construction.begin) | method | Opens an empty draft for one read. | | [`finish`](#nupp.serde.adapters.Construction.finish) | method | Builds the value from a draft the fields have been read into. | #### `begin` _method_ ```nupp begin: function(self): S ``` Opens an empty draft for one read. ##### Arguments | Name | Type | Description | | --- | --- | --- | | `?` | `self` | | ##### Returns | Type | Description | | --- | --- | | `S` | the draft the fields' setters write into | #### `finish` _method_ ```nupp finish: function(self, takes state: S): T ``` Builds the value from a draft the fields have been read into. The structure adapter does not check `required` or `hasDefault` itself, so `finish` is where a field that never arrived is reported or given its default. The draft is transferred to `finish`, which drops it. ##### Arguments | Name | Type | Description | | --- | --- | --- | | `?` | `self` | | | `takes state` | `S` | the draft, after every field present in the input was set | ##### Returns | Type | Description | | --- | --- | | `T` | the value | ### `Conversion` _interface_ ```nupp interface Conversion ... ``` The projection [`convert`](#nupp.serde.adapters.convert) applies: `project` on write, `restore` on read. #### Type parameters | Name | Description | | --- | --- | | `T` | | | `V` | | #### Members | Name | Kind | Description | | --- | --- | --- | | [`project`](#nupp.serde.adapters.Conversion.project) | method | Returns the value the base adapter writes in place of an application value. | | [`restore`](#nupp.serde.adapters.Conversion.restore) | method | Builds the application value from one the base adapter read. | #### `project` _method_ ```nupp project: function(self, borrows value: T): V ``` Returns the value the base adapter writes in place of an application value. ##### Arguments | Name | Type | Description | | --- | --- | --- | | `?` | `self` | | | `borrows value` | `T` | the application value being written | ##### Returns | Type | Description | | --- | --- | | `V` | the projected value | #### `restore` _method_ ```nupp restore: function(self, value: V): T ``` Builds the application value from one the base adapter read. ##### Arguments | Name | Type | Description | | --- | --- | --- | | `?` | `self` | | | `value` | `V` | the value the base adapter read | ##### Returns | Type | Description | | --- | --- | | `T` | the application value | ### `CopyGet` _type_ ```nupp type CopyGet = function(borrows value: T): V ``` Reads a field by copying it out of the value. #### Type parameters | Name | Description | | --- | --- | | `T` | | | `V` | | ### `Field` _interface_ ```nupp interface Field is core.Child ... ``` A field built by [`field`](#nupp.serde.adapters.field), with the operations a codec needs to plan it. #### Type parameters | Name | Description | | --- | --- | | `T` | | | `S` | | | `M` | | #### Members | Name | Kind | Description | | --- | --- | --- | | [`write`](#nupp.serde.adapters.Field.write) | method | Writes the field of a value, or nothing when the value leaves it out. | | [`read`](#nupp.serde.adapters.Field.read) | method | Reads the field's value and stores it into the draft. | | [`accept`](#nupp.serde.adapters.Field.accept) | method | Hands the field's parts to a consumer with the field's value type recovered. | #### `write` _method_ ```nupp write: function(self, borrows source: T, exclusive writer: core.Writer): nil ``` Writes the field of a value, or nothing when the value leaves it out. The structure adapter asks `writer:include` first and calls this only for a member the writer includes. ##### Arguments | Name | Type | Description | | --- | --- | --- | | `?` | `self` | | | `borrows source` | `T` | the value the field is read from | | `exclusive writer` | `core.Writer\` | the writer the field is written to | ##### Returns | Type | Description | | --- | --- | | `nil` | | #### `read` _method_ ```nupp read: function(self, exclusive state: S, exclusive reader: core.Reader): nil ``` Reads the field's value and stores it into the draft. ##### Arguments | Name | Type | Description | | --- | --- | --- | | `?` | `self` | | | `exclusive state` | `S` | the draft being constructed | | `exclusive reader` | `core.Reader\` | the reader positioned at the field's value | ##### Returns | Type | Description | | --- | --- | | `nil` | | #### `accept` _method_ ```nupp accept: function(self, consumer: FieldConsumer): R ``` Hands the field's parts to a consumer with the field's value type recovered. ##### Arguments | Name | Type | Description | | --- | --- | --- | | `?` | `self` | | | `consumer` | `FieldConsumer\` | what to apply to the field | ##### Returns | Type | Description | | --- | --- | | `R` | the consumer's result | ### `FieldConsumer` _interface_ ```nupp interface FieldConsumer ... ``` Visits one field of a structure with its value type recovered. #### Type parameters | Name | Description | | --- | --- | | `T` | | | `S` | | | `M` | | | `R` | | #### Members | Name | Kind | Description | | --- | --- | --- | | [`apply`](#nupp.serde.adapters.FieldConsumer.apply) | method | Receives one field's parts with its value type V in scope. | #### `apply` _method_ ```nupp apply: function( self, member: M, has: Has, get: Get, set: Set, adapter: core.Adapter, fallback: (function(): V)? ): R ``` Receives one field's parts with its value type `V` in scope. ##### Arguments | Name | Type | Description | | --- | --- | --- | | `?` | `self` | | | `member` | `M` | the member the field sits at | | `has` | `Has\` | decides whether a value writes the field; always true when the field was built without `present` | | `get` | `Get\` | reads the field from a value | | `set` | `Set\` | stores a decoded value into the draft | | `adapter` | `core.Adapter\` | the field value's adapter | | `fallback` | `(function(): V)?` | supplies the field's default, or nil when the field carries none of its own | ##### Returns | Type | Description | | --- | --- | | `R` | the consumer's result | ### `Get` _type_ ```nupp type Get = BorrowedGet | CopiedGet ``` A field reader, borrowed or copied. #### Type parameters | Name | Description | | --- | --- | | `T` | | | `V` | | ### `Has` _type_ ```nupp type Has = function(borrows value: T): boolean ``` Decides whether a field is written for a value. #### Type parameters | Name | Description | | --- | --- | | `T` | | ### `IndexedValue` _record_ ```nupp record IndexedValue ... ``` One record of a [`Layout`](#nupp.serde.adapters.Layout), read and written through its slots. #### Members | Name | Kind | Description | | --- | --- | --- | | [`owner`](#nupp.serde.adapters.IndexedValue.owner) | field | | | [`values`](#nupp.serde.adapters.IndexedValue.values) | field | | | [`present`](#nupp.serde.adapters.IndexedValue.present) | field | | | [`has`](#nupp.serde.adapters.IndexedValue.has) | method | Returns whether a slot holds a value, explicit null included. | | [`get`](#nupp.serde.adapters.IndexedValue.get) | method | Returns the value a slot holds. | | [`set`](#nupp.serde.adapters.IndexedValue.set) | method | Stores a value under a slot and marks it present. | | [`remove`](#nupp.serde.adapters.IndexedValue.remove) | method | Clears a slot, making it absent. | #### `owner` _field_ ```nupp owner: table ``` `@private` `@readonly` #### `values` _field_ ```nupp values: {[integer]: unknown} ``` `@private` `@readonly` #### `present` _field_ ```nupp present: {[integer]: boolean} ``` `@private` `@readonly` #### `has` _method_ ```nupp has: function has(self, slot: Slot): boolean ``` Returns whether a slot holds a value, explicit null included. A slot whose adapter reads null holds nil and still counts as present, so `has` tells an explicit null from an absent field where `get` does not. ##### Arguments | Name | Type | Description | | --- | --- | --- | | `self` | `any` | | | `slot` | `Slot\` | the slot to test | ##### Returns | Type | Description | | --- | --- | | `boolean` | whether the slot is present | ##### Raises | Type | Condition | | --- | --- | | `string` | when the slot belongs to another layout | #### `get` _method_ ```nupp get: function get(self, slot: Slot): V? ``` Returns the value a slot holds. A default is not applied here. Decoding stores it when the field is absent, but a value made by the layout's `value` holds nothing until it is set. ##### Arguments | Name | Type | Description | | --- | --- | --- | | `self` | `any` | | | `slot` | `Slot\` | the slot to read | ##### Returns | Type | Description | | --- | --- | | `V?` | the value, or nil when the slot is absent or explicitly null | ##### Raises | Type | Condition | | --- | --- | | `string` | when the slot belongs to another layout | #### `set` _method_ ```nupp set: function set(self, slot: Slot, value: V): nil ``` Stores a value under a slot and marks it present. ##### Arguments | Name | Type | Description | | --- | --- | --- | | `self` | `any` | | | `slot` | `Slot\` | the slot to write | | `value` | `V` | the value, which is nil for an explicit null | ##### Returns | Type | Description | | --- | --- | | `nil` | | ##### Raises | Type | Condition | | --- | --- | | `string` | when the slot belongs to another layout | #### `remove` _method_ ```nupp remove: function remove(self, slot: Slot): nil ``` Clears a slot, making it absent. ##### Arguments | Name | Type | Description | | --- | --- | --- | | `self` | `any` | | | `slot` | `Slot\` | the slot to clear | ##### Returns | Type | Description | | --- | --- | | `nil` | | ##### Raises | Type | Condition | | --- | --- | | `string` | when the slot belongs to another layout | ### `Layout` _interface_ ```nupp interface Layout ... ``` A record whose fields are defined at runtime, for a model that loads its schema rather than generating Nupp types from it. Each field is a typed [`Slot`](#nupp.serde.adapters.Slot) the layout hands out. A value keeps absent and explicitly null fields apart, so a document-shaped protocol can round trip both. ```nupp local serde = require("nupp.serde") local adapters = require("nupp.serde.adapters") local json = require("nupp.serde.json") local plain = json.codec(json.memberNamePolicy) local record Member is serde.Member @readonly name: string @readonly index: integer? end local title = new Member(name = "title") local pages = new Member(name = "pages") local layout = adapters.layout(new Member(name = "Book")) local titleSlot = layout:add(title, adapters.text(title), true) local pagesSlot = layout:addDefault(pages, adapters.float(pages, 64), function(): number return 0 end) local books = layout:binding() local book = plain:decode(books, '{"title":"Dune"}') assert(book:get(titleSlot) == "Dune" and book:get(pagesSlot) == 0) book:set(pagesSlot, 412) assert(plain:encode(books, book) == '{"title":"Dune","pages":412}') ``` #### Type parameters | Name | Description | | --- | --- | | `M` | | #### Members | Name | Kind | Description | | --- | --- | --- | | [`add`](#nupp.serde.adapters.Layout.add) | method | Adds a field with no default. | | [`addDefault`](#nupp.serde.adapters.Layout.addDefault) | method | Adds a field that falls back to a default when absent. | | [`value`](#nupp.serde.adapters.Layout.value) | method | Makes an empty value of this layout, with every field absent. | | [`binding`](#nupp.serde.adapters.Layout.binding) | method | Returns the binding that reads and writes this layout's values. | #### `add` _method_ ```nupp add: function(self, member: M, adapter: core.Adapter, required: boolean): Slot ``` Adds a field with no default. A required field that is absent fails both directions: decoding raises once the input is read, and encoding raises at the field. An optional field that is absent is left out of the output and stays absent on decode. ##### Arguments | Name | Type | Description | | --- | --- | --- | | `?` | `self` | | | `member` | `M` | the member the field sits at | | `adapter` | `core.Adapter\` | the field value's adapter, which must describe `member` | | `required` | `boolean` | whether the field must be present | ##### Returns | Type | Description | | --- | --- | | `Slot\` | the field's slot | ##### Raises | Type | Condition | | --- | --- | | `string` | when the layout is sealed, the adapter describes another member, or the member is already a field | #### `addDefault` _method_ ```nupp addDefault: function( self, member: M, adapter: core.Adapter, default: function(): V ): Slot ``` Adds a field that falls back to a default when absent. Decoding stores the default in a value that lacks the field, so it reads as present. Encoding writes the default for an absent field without storing it. ##### Arguments | Name | Type | Description | | --- | --- | --- | | `?` | `self` | | | `member` | `M` | the member the field sits at | | `adapter` | `core.Adapter\` | the field value's adapter, which must describe `member` | | `default` | `function(): V` | makes the field's default, called each time one is needed | ##### Returns | Type | Description | | --- | --- | | `Slot\` | the field's slot | ##### Raises | Type | Condition | | --- | --- | | `string` | when the layout is sealed, the adapter describes another member, or the member is already a field | #### `value` _method_ ```nupp value: function(self): Value ``` Makes an empty value of this layout, with every field absent. ##### Arguments | Name | Type | Description | | --- | --- | --- | | `?` | `self` | | ##### Returns | Type | Description | | --- | --- | | `Value` | the value | #### `binding` _method_ ```nupp binding: function(self): core.Binding ``` Returns the binding that reads and writes this layout's values. The first call seals the layout, so no field can be added after it, and every call returns the same binding. Fields are written in the order they were added. ##### Arguments | Name | Type | Description | | --- | --- | --- | | `?` | `self` | | ##### Returns | Type | Description | | --- | --- | | `core.Binding\` | the binding | ### `Set` _type_ ```nupp type Set = function(exclusive state: S, value: V): nil ``` Stores a decoded field value into a structure's draft. #### Type parameters | Name | Description | | --- | --- | | `S` | | | `V` | | ### `Slot` _record_ ```nupp record Slot ... ``` A typed field of a [`Layout`](#nupp.serde.adapters.Layout). #### Type parameters | Name | Description | | --- | --- | | `V` | | #### Members | Name | Kind | Description | | --- | --- | --- | | [`owner`](#nupp.serde.adapters.Slot.owner) | field | | | [`position`](#nupp.serde.adapters.Slot.position) | field | | | [`valueType`](#nupp.serde.adapters.Slot.valueType) | field | | #### `owner` _field_ ```nupp owner: table ``` `@private` `@readonly` #### `position` _field_ ```nupp position: integer ``` `@private` `@readonly` #### `valueType` _field_ ```nupp valueType: (function(value: V): V)? ``` `@private` `@readonly` ### `StructureConsumer` _interface_ ```nupp interface StructureConsumer ... ``` Visits a structure adapter's fields and construction. See [`inspect`](#nupp.serde.adapters.inspect). #### Type parameters | Name | Description | | --- | --- | | `T` | | | `M` | | | `R` | | #### Members | Name | Kind | Description | | --- | --- | --- | | [`apply`](#nupp.serde.adapters.StructureConsumer.apply) | method | Receives a structure adapter's parts with its draft type S in scope. | #### `apply` _method_ ```nupp apply: function( self, member: M, fields: const{Field}, construction: Construction, unknown: core.UnknownConsumer, additional: core.Members? ): R ``` Receives a structure adapter's parts with its draft type `S` in scope. ##### Arguments | Name | Type | Description | | --- | --- | --- | | `?` | `self` | | | `member` | `M` | the member the structure sits at | | `fields` | `const{Field\}` | the fields, in write order | | `construction` | `Construction\` | how the structure opens and finishes its draft | | `unknown` | `core.UnknownConsumer\` | what the structure does with undeclared wire fields; the rejecting consumer when the adapter was built without one | | `additional` | `core.Members\?` | the extra members written after the fields, or nil | ##### Returns | Type | Description | | --- | --- | | `R` | the consumer's result | ## Functions ### `atom` _function_ ```nupp function atom(member: M): core.Adapter ``` A model-defined `nupp.serde.Atom`, passed through uninterpreted. #### Type parameters | Name | Description | | --- | --- | | `M` | | #### Arguments | Name | Type | Description | | --- | --- | --- | | `member` | `M` | | #### Returns | Type | Description | | --- | --- | | `core.Adapter\` | | ### `bigInteger` _function_ ```nupp function bigInteger(member: M): core.Adapter ``` An integer of unbounded size, carried as its decimal text. #### Type parameters | Name | Description | | --- | --- | | `M` | | #### Arguments | Name | Type | Description | | --- | --- | --- | | `member` | `M` | | #### Returns | Type | Description | | --- | --- | | `core.Adapter\` | | ### `boolean` _function_ ```nupp function boolean(member: M): core.Adapter ``` A boolean. #### Type parameters | Name | Description | | --- | --- | | `M` | | #### Arguments | Name | Type | Description | | --- | --- | --- | | `member` | `M` | | #### Returns | Type | Description | | --- | --- | | `core.Adapter\` | | ### `borrowedGet` _function_ ```nupp function borrowedGet(read: BorrowGet): Get ``` Wraps a borrowing field reader. #### Type parameters | Name | Description | | --- | --- | | `T` | | | `V` | | #### Arguments | Name | Type | Description | | --- | --- | --- | | `read` | `BorrowGet\` | | #### Returns | Type | Description | | --- | --- | | `Get\` | | ### `bytes` _function_ ```nupp function bytes(member: M): core.Adapter ``` Binary data. JSON writes it as base64. #### Type parameters | Name | Description | | --- | --- | | `M` | | #### Arguments | Name | Type | Description | | --- | --- | --- | | `member` | `M` | | #### Returns | Type | Description | | --- | --- | | `core.Adapter\` | | ### `convert` _function_ ```nupp function convert(base: core.Adapter, conversion: Conversion): core.Adapter ``` Converts between an application value and one an adapter already handles. ```nupp local serde = require("nupp.serde") local adapters = require("nupp.serde.adapters") local json = require("nupp.serde.json") local plain = json.codec(json.memberNamePolicy) local record Member is serde.Member @readonly name: string @readonly index: integer? end local record Celsius degrees: number end local record Degrees is adapters.Conversion function project(self, borrows value: Celsius): number return value.degrees end function restore(self, value: number): Celsius return new Celsius(degrees = value) end end local member = new Member(name = "temperature") local temperature: serde.Binding = new serde.Bound( adapter = adapters.convert(adapters.float(member, 64), new Degrees()) ) assert(plain:encode(temperature, new Celsius(degrees = 21.5)) == "21.5") ``` #### Type parameters | Name | Description | | --- | --- | | `T` | | | `V` | | | `M` | | #### Arguments | Name | Type | Description | | --- | --- | --- | | `base` | `core.Adapter\` | | | `conversion` | `Conversion\` | | #### Returns | Type | Description | | --- | --- | | `core.Adapter\` | | ### `copiedGet` _function_ ```nupp function copiedGet(read: CopyGet): Get ``` Wraps a copying field reader, for a field computed rather than stored. #### Type parameters | Name | Description | | --- | --- | | `T` | | | `V` | | #### Arguments | Name | Type | Description | | --- | --- | --- | | `read` | `CopyGet\` | | #### Returns | Type | Description | | --- | --- | | `Get\` | | ### `decimal` _function_ ```nupp function decimal(member: M): core.Adapter ``` An exact decimal, as a `nupp.serde.Decimal`. #### Type parameters | Name | Description | | --- | --- | | `M` | | #### Arguments | Name | Type | Description | | --- | --- | --- | | `member` | `M` | | #### Returns | Type | Description | | --- | --- | | `core.Adapter\` | | ### `document` _function_ ```nupp function document(member: M, adapter: core.DocumentAdapter): core.Adapter ``` A document-valued member: a value with no schema of its own, read and written through a document adapter such as `nupp.serde.document.adapter`. ```nupp local serde = require("nupp.serde") local adapters = require("nupp.serde.adapters") local document = require("nupp.serde.document") local json = require("nupp.serde.json") local plain = json.codec(json.memberNamePolicy) local record Member is serde.Member @readonly name: string @readonly index: integer? end local payload: serde.Binding = new serde.Bound( adapter = adapters.document(new Member(name = "payload"), document.adapter()) ) assert(assert(plain:decode(payload, '{"any":[1,true]}'):get("any")):size() == 2) ``` #### Type parameters | Name | Description | | --- | --- | | `D` | | | `M` | | #### Arguments | Name | Type | Description | | --- | --- | --- | | `member` | `M` | | | `adapter` | `core.DocumentAdapter\` | | #### Returns | Type | Description | | --- | --- | | `core.Adapter\` | | ### `field` _function_ ```nupp function field(member: M, get: BorrowGet, set: Set, adapter: core.Adapter, required: boolean, hasDefault: boolean, present: Has?): Field ``` One field of a [`structure`](#nupp.serde.adapters.structure). `get` borrows the field from the value on write and `set` stores a decoded one into the draft on read. A `required` field must be present when reading; `hasDefault` tells codecs the construction supplies one, so the field may be absent. `present`, when given, decides per value whether the field is written at all. #### Type parameters | Name | Description | | --- | --- | | `T` | | | `S` | | | `V` | | | `M` | | #### Arguments | Name | Type | Description | | --- | --- | --- | | `member` | `M` | | | `get` | `BorrowGet\` | | | `set` | `Set\` | | | `adapter` | `core.Adapter\` | | | `required` | `boolean` | | | `hasDefault` | `boolean` | | | `present` | `Has\?` | | #### Returns | Type | Description | | --- | --- | | `Field\` | | ### `float` _function_ ```nupp function float(member: M, width: 32 | 64): core.Adapter ``` A floating-point number written at a fixed width. A 32-bit float is rounded on write, so a codec that keeps widths, such as `nupp.serde.native`, restores the value it would have had in a `float32`. #### Type parameters | Name | Description | | --- | --- | | `M` | | #### Arguments | Name | Type | Description | | --- | --- | --- | | `member` | `M` | | | `width` | `32 | 64` | | #### Returns | Type | Description | | --- | --- | | `core.Adapter\` | | ### `inspect` _function_ ```nupp function inspect(selected: core.Adapter, consumer: Consumer): R? ``` Opens a [`structure`](#nupp.serde.adapters.structure) adapter to a consumer, for a codec that plans its own field layout, such as one that assigns binary field numbers. #### Type parameters | Name | Description | | --- | --- | | `T` | | | `M` | | | `R` | | #### Arguments | Name | Type | Description | | --- | --- | --- | | `selected` | `core.Adapter\` | | | `consumer` | `Consumer\` | | #### Returns | Type | Description | | --- | --- | | `R?` | | ### `integer` _function_ ```nupp function integer(member: M, width: 8 | 16 | 32 | 64, signed: boolean): core.Adapter ``` An integer of a fixed width and signedness, as a `nupp.serde.Integer`. The codec checks the range on both sides, so a 64-bit value round-trips exactly on every target. Use [`convert`](#nupp.serde.adapters.convert) to expose it as a plain `integer`. #### Type parameters | Name | Description | | --- | --- | | `M` | | #### Arguments | Name | Type | Description | | --- | --- | --- | | `member` | `M` | | | `width` | `8 | 16 | 32 | 64` | | | `signed` | `boolean` | | #### Returns | Type | Description | | --- | --- | | `core.Adapter\` | | ### `layout` _function_ ```nupp function layout(member: M): Layout ``` Starts an empty [`Layout`](#nupp.serde.adapters.Layout). #### Type parameters | Name | Description | | --- | --- | | `M` | | #### Arguments | Name | Type | Description | | --- | --- | --- | | `member` | `M` | | #### Returns | Type | Description | | --- | --- | | `Layout\` | | ### `list` _function_ ```nupp function list(member: M, element: M, adapter: core.Adapter): core.Adapter<{V}, M> ``` A list of values that share one element adapter. #### Type parameters | Name | Description | | --- | --- | | `V` | | | `M` | | #### Arguments | Name | Type | Description | | --- | --- | --- | | `member` | `M` | | | `element` | `M` | | | `adapter` | `core.Adapter\` | | #### Returns | Type | Description | | --- | --- | | `core.Adapter\<{V}, M\>` | | ### `structure` _function_ ```nupp function structure(member: M, fields: const{Field}, construction: Construction, unknown: core.UnknownConsumer?, additional: core.Members?, deferredConstruction: boolean?): core.Adapter ``` A structure: named fields written in order, read in any order, and constructed through an exclusive draft. Reading calls `construction:begin()`, applies each field's setter to the draft as the codec meets it, then hands the draft to `construction:finish()`. A wire field the model does not declare is passed to `unknown`, which rejects it when nil. `additional` emits extra members after the declared ones, such as preserved unknown fields. #### Type parameters | Name | Description | | --- | --- | | `T` | | | `S` | | | `M` | | #### Arguments | Name | Type | Description | | --- | --- | --- | | `member` | `M` | | | `fields` | `const{Field\}` | | | `construction` | `Construction\` | | | `unknown` | `core.UnknownConsumer\?` | | | `additional` | `core.Members\?` | | | `deferredConstruction` | `boolean?` | | #### Returns | Type | Description | | --- | --- | | `core.Adapter\` | | ### `text` _function_ ```nupp function text(member: M): core.Adapter ``` A UTF-8 string. #### Type parameters | Name | Description | | --- | --- | | `M` | | #### Arguments | Name | Type | Description | | --- | --- | --- | | `member` | `M` | | #### Returns | Type | Description | | --- | --- | | `core.Adapter\` | | ### `timestamp` _function_ ```nupp function timestamp(member: M): core.Adapter ``` An instant, as a `nupp.serde.Timestamp`. The codec policy chooses its text or numeric form. #### Type parameters | Name | Description | | --- | --- | | `M` | | #### Arguments | Name | Type | Description | | --- | --- | --- | | `member` | `M` | | #### Returns | Type | Description | | --- | --- | | `core.Adapter\` | |