Sounds like you took care of it well.
For those considering in the future, I'd say you can cancel class. There's no need to be very specific in your reasoning for why to the students.
As a TA, I was to make a 4 hour drive back to campus after a weekend away, and my car wouldn't start. Not much I could do. Not a situation I was excited to explain. But not one with much choice at that point. It means less learning time, which is no good for anyone (if you are properly interested in seeing them learn as much as possible as well!). But there are all kinds of reasons people cancel class, many where teachers don't want to go into details. And even some potentially valid ones involved with class preparation (a large project/test you'd built the class time around suddenly disappearing into the computing void, vital class materials not coming in, etc). It's not something you should consider lightly, but if it's important to cancel class, then it's important to cancel class. You're fairly unlikely to get significant challenge. The only ones who really might be in a situation to challenge you are your superiors. But even in that less likely circumstance, you can try repeating the limited explanation... or give a full explanation (they may not be TOO happy with it, but they'll probably just have to take it, give a warning about being prepared, and move on). If you you've done your best and you're really convinced it's the best option, you do what you have to do, you take any consequences it takes, and you move forward. Quality teachers sometimes have to face unhappy individuals, and if it's your fault, that you didn't pay enough attention to the course plan or did not prepare soon enough, you commit to working hard so it doesn't happen again, and then you deal with the current fallout. You can't change the past, you can only make the best choices in the current. And if that means canceling classes, so be it.
But, indeed, see if you can adapt your class so that you don't have to cancel to get around the trouble. Review, cover a topic scheduled for another time, focus on the background aspects that you do understand, show a video, whatever will usefully consume the time. Usefully being the key word. Cancelling isn't the worst option. Wasting time is worse. Maybe not to how you are thought of, but to the betterment of your students.
If you do have to cancel, try your best to supplement the missed time. Send out extra homework. Make a YouTube video lecture. Put together an application project. If the students are expected to check electronic medium, you can probably fairly expect them to do it (you could also put a printed copy of your message on the classroom door for any who may unaware come to the classroom). If they aren't expected to keep track of media, you can probably still reasonably expect them to make up some of the lost time with a bit of extra homework later. Meet them in the middle, you don't want to swamp their schedule, especially with busywork, but giving them, for instance, a 20 minute video lecture + practice problems posted later in the week when it was to be an hour class probably won't be seen as too problematic for most... and you can be a little more adaptable if there are some that maybe don't have scheduling flexibility to do more extra work outside of class later in the week. The point is, you try to do your job the best you can, and be supportive to them in doing it, they'll meet you half way. I believe every student did the replacement work that I sent out for that class that I missed 11 years ago. Undergraduates usually are so excited to get an hour off classwork, they don't mind doing a bit of extra work at home!
Not understanding material well can be a very dangerous situation. I saw one of the other answers or comments suggested that being transparent on such shortcomings would lead to revolt, but the alternative, pretending that you know it well when you don't, can be absolutely devastating. In situations like a preset college course, maybe you don't tell them you're struggling. But you also work very hard to get ahead of it. Going in and trying to work a few "simple" problems when you're struggling with the topic is just asking for a mess. The one thing worse than cancelling class or delaying (or even skipping) material is to come into class and teach it wrong, make repeated mistakes, and absolutely confuse everyone. We've probably all had teachers come in and absolutely make a mess of problems, and we left understanding the material less than before. I had a teacher in my major who repeatedly did that. That's where you lose control of a class, when you pretend to know what you're doing but don't show it. Your number one job as a teacher isn't keeping the schedule, but making sure you're improving upon any that they learn independently. As such, in many courses, textbook reading is required. Indeed, in many courses the the expectation isn't that they're necessarily reading it all the time before class. But when they do reading, most students should at least a loose handle on the information. Coming in and making mistakes is bound to destroy that. If indeed you cancelled class, emphasize to them that this is the one time where the textbook reading is even more necessary, so that you are able to pick up moving ahead next week, and reduce the hit of the missed class.
I've certainly been hit with situations through the years where I had new material to suddenly teach. As a private school teacher, I often substituted in a variety of courses. Or in my own classes, like chemistry or history, I offered a little freedom to investigate any topics that particularly interested my students... and ended up doing cram sessions on stomach digestion or Native American tribes. Students threw new-fangled common core math approaches at me, and occasionally it'd appear so abstruse that I needed to pass on it until next class to not waste time and focus. No one expects us to know everything. Even a major professor will get a question they don't know how to answer occasionally, or a problem that they'll manage to struggle with unexpectedly. Instead of trying to force it, take a step back, tell them you'll look back into it further, and then follow up the next week, or online, (or directly to the student outside of class, if it's indeed an unnecessary tangent that will be more detriment than gain to other students). Pretending to know something you don't seems the cardinal sin in teaching. It suggests the students should have learn the same undercurrents of pride and dishonesty. It may not be quite so fitting for college courses, but there are definitely many teaching situations where you should admit to your students you don't perfectly understand. It shows them that you're not so different from them and need to work at it sometimes too**. And ends up encouraging confidence and effort from the students who need it most.
And you did well. If you're hit with a situation where you're just not making it, don't be afraid to ask for help. You may be embarrassed, you may even look poor in the eyes of your superior, but it's better to do what is necessary than to pretend. There's no guarantees you'll get the help, but there's often a wealth of assistance right at your front door if you'll just be bold enough to seek it.
Overall, you adapted. You fought hard to overcome it, and you kept the best interest of your students at the front. Decorum be darned, that's what teaching is all about. And we need more teachers doing that!