How to build typed StructArrays from NTuples

In the documentation of StructArrays, the Advanced techniques · StructArrays section describes how custom structs could be passed to a StructArray constructor by overloading component, createinstance and staticschema. However, I can’t figure how to apply this to a single case.

Here is a toy example

using StructArrays
# My custom struct
struct Mystruct
# Some data source returning NTuples
A = [(a=1,b=2), (a=3,b=4)]

# Desired container
struct ContainerS
# What works for now
struct ContainerA

Due to the identity in the named tuple and struct types and names, overloading staticschema does not seem to be necessary. StructVector(A) returns

julia> StructVector(A)
2-element StructArray(::Vector{Int64}, ::Vector{Int64}) with eltype @NamedTuple{a::Int64, b::Int64}:
 (a = 1, b = 2)
 (a = 3, b = 4)

obviously, Mystruct is missing, but StructVector{Mystruct}(A,dims=1) errrors with

ERROR: ArgumentError: only eltypes with fields are supported

so createinstance and component should be overloaded still.

In the meantime, if I do ContainerS(StructVector(A)) this errors with

ERROR: MethodError: Cannot convert an object of type
StructVector{@NamedTuple{a::Int64, b::Int64}, @NamedTuple{a::Vector{Int64}, b::Vector{Int64}}, Int64} to an object of type

but if I use a container with an abstract type ContainerA(StructVector(A)) it works, but I’m left with an abstract typed field.

Can somone explain

  1. How to properly overload component and createinstance ?
  2. Why it works fine with the abstract typed field ?