mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-24 18:03:25 +00:00
Move smoltcp-related code to bigtcp
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
9fba9445bd
commit
67d3682116
18
kernel/libs/aster-bigtcp/src/device.rs
Normal file
18
kernel/libs/aster-bigtcp/src/device.rs
Normal file
@ -0,0 +1,18 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
pub use smoltcp::phy::{Device, Loopback, Medium};
|
||||
|
||||
/// A trait that allows to obtain a mutable reference of [`Device`].
|
||||
///
|
||||
/// A [`Device`] is usually protected by a lock (e.g., a spin lock or a mutex), and it may be
|
||||
/// stored behind a shared type (e.g., an `Arc`). This property abstracts this fact by providing a
|
||||
/// method that the caller can use to get the mutable reference without worrying about how the
|
||||
/// reference is obtained.
|
||||
pub trait WithDevice: Send + Sync {
|
||||
type Device: Device + ?Sized;
|
||||
|
||||
/// Calls the closure with a mutable reference of [`Device`].
|
||||
fn with<F, R>(&self, f: F) -> R
|
||||
where
|
||||
F: FnOnce(&mut Self::Device) -> R;
|
||||
}
|
Reference in New Issue
Block a user