I'm so sorry to hear about this.
My sister did the same thing to a cockatiel she had when she was younger. I guess part of the reason why we end up making these mistakes is that while asleep, we expect ourselves to be conscious enough to hold still and not move too much. Truth is though, when we're asleep any movements we have are involuntary since they're often instinctive in order for us to get comfortable (except for the case of sleep walking, which is often our subconscious taking over the body while we dream, I think). I think another part of the reason why this mistake is made is because we expect our birds to move out of the way when we roll over. And sometimes they don't because they're either too comfy, also sleeping, or in a position where they can't really get out of the way in time. Heck my dog doesn't get out of the way if he sleeps with me sometimes. Instead he'll just growl or something (luckily he sleeps near my feet during the times I let him in the bed; he knows that I move around a lot in m sleep).
Birds are fragile animals (in the terms of physical body structure), and even when we're being as careful as we can, accidents can happen. Unfortunately some of the worst things happen in the form of accidents, and we can't do anything about them other than to learn our lesson and not repeat the mistakes that cause these accidents.
I can tell you not to blame yourself for this happening, but I know exactly how hard it is to keep from doing just that. The best thing I can say I guess, is remember that you've given Rio an excellent life, and the entire time he loved you as much as you loved him (possibly more. The amount of affection birds can have for us is amazing).