I have food allergies and therefore some eating restrictions. If I suspect that I'm not going to be able to eat much or any of the food at someone's house, I warn them in advance so that they don't prepare too much and are not offended if I skip things. But I eat before I go, or just go hungry and eat when I return home. I think it's rude to bring your own food to a meal that someone has cooked and offered you at their home, if the hospitality is about the meal. And, if you don't have blood sugar issues.
If you're going to be at an event for 5 hours, and you can't go 5 hours without food for blood sugar/health reasons, then, I think it's fair to explain it to the host, and perhaps some of the other guests, and then bring what you can eat. Or if everyone's getting together for an event that's not food related like a football game or something on TV, and the hosts are just ordering something like takeout or pizza and you'd like to eat something else, then I don't think it's rude to ask the host's permission and see if you can bring something else.
But if you've been invited to an event that centers around a meal, around homecooked food that might take at least 30 minutes to prepare, then I think it's rude to bring your own food. You should just eat beforehand and not eat when others are eating. JMHO.