module: document the API and simplify the code

This does NOT change the module API/ABI in any way.
3 jobs for <span class="ref-name">module-refactor</span> in 1 minute and 46 seconds
Status Job ID Name Coverage
  Build
passed #1873
docker linux amd64
build:linux:amd64

00:00:29

 
  Test
passed #1875
docker linux amd64
deckard:linux:amd64

00:00:54

passed #1874
docker linux amd64
test:linux:amd64

00:00:22