MsgpackDateTime.StructWrap (msgpack_datetime v0.2.0)
View SourceRewrap an Elixir %ElixirStruct{} struct into an Erlang {module, ElixirStruct} struct,
or vice versa.
iex> dt = ~U[2025-12-10 12:53:25Z]
...> assert :msgpack.pack(dt |> MsgpackDateTime.StructWrap.wrap(), ext: MsgpackDateTime)
...> === <<214, 255, 105, 57, 109, 69>>
...>
...> {:ok, unpacked} = :msgpack.unpack("\x93\xC4\x06record\xD6\xFFi9mE\xCD\x01\xA4", ext: MsgpackDateTime)
...> assert unpacked |> MsgpackDateTime.StructWrap.unwrap()
...> === ["record", dt, 420]
Summary
Functions
unwrap(term, DateTime, MsgpackDateTime)
Walk term and convert all list items and map values, recursively, from being {erlang_struct, %elixir_struct{}} to being %elixir_struct{}. All other nested terms are unchanged.
wrap(term, DateTime, MsgpackDateTime)
Walk term and convert all list items and map values, recursively, from being %elixir_struct{} to being {erlang_struct, %elixir_struct{}}. All other nested terms are unchanged.
Functions
unwrap(term, DateTime, MsgpackDateTime)
Walk term and convert all list items and map values, recursively, from being {erlang_struct, %elixir_struct{}} to being %elixir_struct{}. All other nested terms are unchanged.
wrap(term, DateTime, MsgpackDateTime)
Walk term and convert all list items and map values, recursively, from being %elixir_struct{} to being {erlang_struct, %elixir_struct{}}. All other nested terms are unchanged.