You lucky person you...I love Edinburgh. They have some of the best pubs along the Royal Mile leading to their castle.
Anyway to answer your question. Typically you are booked straight through to your destination. (Make sure your luggage gets booked straight through too.) Which means you'll wait in Toronto inside the international terminal and inside their secure area.
So during the layover, in TOR you can stay inside the secure area and not go through security/ customs/ passport.
But stay inside the secure area. There are typically shops and restaurants inside the secure areas so you need not leave them. If you do leave those area, then yes you'll need to do them all over again.
NOTE: While the above is all true, as a seasoned overseas traveler by air, sometimes I have been surprised. I landed in Vienna as a layover to catch the next leg to Kosovo. Both are international flights, in and out of Vienna.
I figured we'd (I was with my wife) just stay inside the secure area after arriving and wait there to take the Kosovo flight. In fact, the flight attendant assured us that our outgoing flight would be boarding at the gate right next to our arrival gate.
Did not happen that way.
For whatever reason known only to the Austrians, upon arrival we had to leave our secure area to walk all the way through the terminal to the other end to catch our outgoing flight. And that meant we went through passport and customs to leave the secure area after landing in Vienna and then...go through security, and passport again to enter a new secure area for the Kosovo flight.
In other words we had to stand in two long and very slow lines coming and going through Vienna. We almost missed our connection to Kosovo. My point, expect the unexpected in international flights, especially into and out of small airports.