Segment vs toolbar

I am a beginner in ionic and now i have to implement a screen. And reading the documentation i am a bit confused. What is the difference between a segment and a toolbar and when to use each one?
As design they look similar and i think i can use any of them.

They may look similar in the documentation because the segment is contained within a toolbar in the documentation.

I use a segment to conditionally show data. Think of a file folder with multiple tabs inside. When you pull the folder out of the drawer, you have all of the information but might only want to see some of it at one time.

I have found that the segment must be nested in a toolbar or div. otherwise, you will notice that there is part of the segment that appears not to be fully rendered when it is in a not-active state.