1. 09 Jun, 2021 1 commit
    • Daniel Martí's avatar
      node/bindnode: rethink and better document APIs · 2fc002c2
      Daniel Martí authored
      Before, we envisioned exposing the following APIs:
      
      	Prototype
      	PrototypeNoSchema
      	PrototypeOnlySchema
      	Wrap
      	WrapNoSchema
      
      The names were long, though, and perhaps a bit confusing too. Instead,
      just expose Prototype and Wrap, and allow either of the parameters to be
      nil to infer its value. This makes the API easier to navigate, and we
      can concentrate documentation in fewer places.
      
      Now there's two main entrypoints: Prototype if one wants a high-level
      prototype to create nodes of a certain shape, and Wrap if one wants to
      expose an existing Go value as an IPLD node. Whether one supplies only
      an IPLD Schema, only a Go type/value, or both, is their choice. The only
      exception is Wrap, which always requires a Go value by definition.
      
      Wrap works now, too, and gains an example. It's the same idea as the
      previous Prototype example, but it builds the value via a Go composite
      literal rather than fluent/qp on the IPLD side.
      
      Another noteworthy change is that we now return TypedPrototype and
      TypedNode rather than the regular NodePrototype and Node interfaces,
      since bindnode always works with a schema - even when it's inferred.
      The big advantage here is that one can call the Representation method
      directly on the result without having to type assert, like the example
      does.
      2fc002c2
  2. 25 May, 2021 1 commit
    • Daniel Martí's avatar
      node/bindnode: start of a reflect-based Node implementation · 806e36fb
      Daniel Martí authored
      Lots of TODOs and polishing to do, but it passes the schema/gen/go tests
      with minimal changes.
      
      Follow-up commits will continue filling in the gaps and adding
      documentation, notably examples. We'll also make the tests run by
      default, after a bit of refactoring.
      806e36fb