mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-26 10:53:25 +00:00
For TCP streams we have packed their different states with `Arc`, e.g. `InitStream`, `ConnectedStream`, and `ListenStream`. Later we will implement an trait that observes iface events for some of these states. For UDP datagrams, they can be in the unbound state and the bound state. If we want to implement the observer trait for the bound state, we need to wrap it with `Arc` so that it can be registered with `AnyBoundSocket`. Alternatively, we can implement the observer trait directly on the UDP datagram structure (i.e. `DatagramSocket`). However, there are literally no events to handle if the socket is not bound at all (i.e. it is in the unbound state). So a more efficient way is to implement the observer trait only for the bound state, which motivates changes in this commit.