api: add patrun exporting function

as per title :)
need this in patrun-viz

thanks!