How should I build a garden fence on the edge of a swamp?
Well, there is a whole university of thought on how to best keep fence posts from rotting. There are also quite a few good answers on this site - try searching "fence post rot".  Some of them are linked below:

Why did a gate post rot after just 6 years?

Using PT (Pressure-Treated) posts

Setting in dirt vs. gravel vs. concrete

In general, water is not necessarily bad for wood - it is the combination of water and air that allows microbes to grow and causes rot.  On our farm, we usually use bare cedar posts for our wire fence, which hold up pretty well, but we still end up replacing them every 5-7 years.  For structural posts, or where we want to hang nice wooden fencing on the posts (sounds like your application), we generally coat the bottom few feet with creosote, which helps somewhat with minimizing water penetration (depending on whether you soak or paint it), but mostly keeps the air from getting in.  The most important part is to extend the coating about 6 inches above the soil, to complete the barrier.  Personally, I don't know whether the coating could affect the fungi - I would go for actual creosote, as opposed to the CCA compounds, but both can have health risks.