How to provide PCB protective layer
It really depends on the application. 

If it is intended for indoor only in non condensing environments then you do not need a coating. Nothing will rust unless you are using steel screws or other fastenings. 

If it is for a high humidity environment where condensation is likely then a conformal coating may be sufficient. There are a wide variety of options.

If it is intended for outdoor use where rain or other sources of water may enter the enclosure then "potting" the board in a resin or other material is usually required.

If all cases, especially where components are expected to get hot, special care must be taken to ensure that the heat transfer can still be maintained.

A wide variety of proper materials are available specifically for this purpose on the market that have the appropriate ratings and approvals. Many are specifically designed to have good heat transfer characteristics. I have to recommend you use one of these for your safety and the safety of anyone that might be using your boards.