I was recently hit by a car which pulled onto a roundabout. The driver hadn't seen me. The car hit me hard enough to actually snap the rim of my rear wheel. The bike has a carbon fibre frame and fork. It looks OK but the rear wheel is totalled I can't ride it. How should I assess whether to rebuild or replace the bike?
The first thing is to clean the entire frame and fork very carefully and look for cracks or irregularities. I like to use something like a squirt bottle silicone cleaner/polish for this, along with a microfiber finishing rag, because it kind of normalizes the surface and makes things easier to pick out. Look extra carefully all around the joints, particular of the chain and seatstays, which is a place where rear end impacts are particularly likely to cause cracking on carbon road bikes in my experience.
If you find anything where you can't tell whether it's a crack in the frame or just the paint, chip away the paint to look underneath.
Presuming you find nothing, you're faced with an ambiguity that is best considered to be part of the cost of admission to carbon bikes. In other fields there are ways of using x-rays to look for unseen damage to carbon fiber structures, but it's considered impractical for bikes cost-wise and is not done. All anyone can do is guess.
Cleaning the frame and inspecting for damage is a good first step. Inspect the frame for any marks in the carbon on the surface. If you don't find any, then it's a good sign, but this won't reveal any damage or stress under the surface. If you find damage, you need to determine if it's scuffed paint or cracked carbon.
To work this out, start by flexing or squeezing that part of the frame. If it has more flex than a similar part of the bike without damage, then it's in the carbon (🙁). If you hear any noise (often sounds like scrunching paper or crushing corn flakes) while flexing it,then it's in the carbon (🙁). If it passes these two tests, it's a good sign but doesn't mean that your frame is fine yet (thick carbon like a steerer or seatpost can pass these when broken).
Next step is to get something hard (I use a 5mm allen key as my tuning fork) to tap on the frame to hear the sound. If the concerning scrape is halfway down the seattube, then you start gently tapping the frame at the top of the seattube, gradually working down past the crack right to the other end. If the sound is the same sharp tapping all the way, then it's a very good sign that the damage is superficial and you just need to polish up the clear coat. If the sound is sharper at the top, then a duller thudding sound at the crack, then the damage is structural (🙁).
I've done this long enough that I no longer bother with the visual inspection and just go straight to the tapping test all over the bike. Start with both fork legs, then the seatstays and chainstays. Next is the headtube, toptube, seattube and seatpost (most common break that I see). I finish at the downtube (I'm yet to find a busted downtube that wasnt very visibly snapped) tapping right down along the top side, then along the bottom side. If no damage is found by this point, remove the fork from the bike to perform the same test on the steerer tube (undetected failures here have proven fatal).
If the crashed bike has a carbon fork with an alloy steerer, then I will never tell someone that their bike is safe, because there have been multiple documented fatalities from failures of such forks after having been crashed. I'm not sure how to check one of these for that sort of damage (alloy section separates from the carbon).
I want to emphasise that I gave you an order to inspect the parts of the frame. This order is arbitrary and no better than any other, but by following it, you'll know that there won't be anything that you've missed. Be most methodical around the junctions between tubes. One side of the bottom bracket might give you a nice sharp tap, while the other gives a dull thud (🙁). When in doubt, keep tapping.
Carbon frames should be strong and stiff, with only a little flex so also try flexing the whole frame and if you find a spot with more give, then inspect it more closely (pencil-thin seatstays will always flex more than a downtube, but if one flexes more than the other, then it may have carbon damage).
This advice is not something a beginner should attempt. If you haven't been working on bikes and riding carbon for some time, then just take it to a reputable shop to make this call. A mistake here could lead to a failure at speed. Lives have been lost from such mistakes.
Completely disassemble the bike and have the frame x-rayed. It's only the really sure way to know. The frame will normally crack around installed components which have less resiliency than the carbon fiber.