pub struct MacVendorCache { /* private fields */ }
Expand description
A thread-safe cache for storing and retrieving MAC addresses and their associated vendor names.
The MacVendorCache
struct is designed to store mappings between MAC addresses and vendor names
in a thread-safe manner using an Arc<Mutex<HashMap<MacAddress, Vendor>>>
. This ensures that
the cache can be accessed and modified safely across multiple threads.
Trait Implementations§
Source§impl Clone for MacVendorCache
impl Clone for MacVendorCache
Source§fn clone(&self) -> MacVendorCache
fn clone(&self) -> MacVendorCache
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl IMacVendorCache for MacVendorCache
impl IMacVendorCache for MacVendorCache
Source§fn new() -> Self
fn new() -> Self
Creates a new instance of MacVendorCache
.
The cache is initialized as an empty HashMap
protected by a Mutex
to allow safe concurrent access.
§Returns
A new, empty MacVendorCache
.
Source§fn add(&self, mac_addr: String, vendor_name: String)
fn add(&self, mac_addr: String, vendor_name: String)
Adds a new MAC address and its associated vendor name to the cache.
If the MAC address already exists in the cache, its associated vendor name will be updated.
§Arguments
mac_addr
- The MAC address to be added to the cache.vendor_name
- The name of the vendor associated with the MAC address.
Source§fn get(&self, mac_addr: &String) -> String
fn get(&self, mac_addr: &String) -> String
Retrieves the vendor name associated with a given MAC address.
If the MAC address is not found in the cache, the function returns "Unknown"
.
§Arguments
mac_addr
- The MAC address whose associated vendor name is to be retrieved.
§Returns
The vendor name associated with the MAC address, or "Unknown"
if the MAC address
is not found in the cache.
Auto Trait Implementations§
impl Freeze for MacVendorCache
impl RefUnwindSafe for MacVendorCache
impl Send for MacVendorCache
impl Sync for MacVendorCache
impl Unpin for MacVendorCache
impl UnwindSafe for MacVendorCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more