I don't know if rat walls were technically required, but I wanted one anyway, to keep critters out from beneath my slab. I am positive I would have a family of skunks, groundhogs, or rabbits living under my slab if I didn't do it. When I mentioned it to my local township inspector, he nodded approvingly, but I didn't clarify if it was actually a requirement.
I don't get why you really care how long the wood or foam will last in the ground. It might rot, but it won't just vaporize into thin air. Aren't you going to backfill on the outside of the barn also? If you have earth on the outside of the building, then nothing will spill out from under your slab in the event of woot or foam rot. In any case, a well supported slab with proper rebar in it isn't going to fall apart if only the very edges become unsupported.
I don't have very good pics or my ratwall process, still had an old iPhone back then. I forgot that I didn't dig precisely between the posts, and elected to run my ratwall mostly inside the posts. I think this was because the digging was just too annoying, and I had an excavator on hand, so I could easily dig inside the posts. I think I was also somewhat nervous about fully de-stabilizing the posts.
But on the other side I did navigate between the posts some, and bump the ratwall out (into the building interior) around the posts).
Then I compacted the crap out of my sandy soil subgrade before foam board, vapor barrier, pex tubing and rebar install. Notice the extra foam board strips atop the rat wall, inside the skirt board, to insulate the exterior of the main slab edge (important!)
More pics of the slab prep available if you want to see.