mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-04-24 18:52:14 +00:00
Add as_ref and as_mut functions to Toggle (#1684)
This commit is contained in:
parent
32df8ea192
commit
b6ec95eb77
@ -51,6 +51,16 @@ impl<TBehaviour> Toggle<TBehaviour> {
|
||||
pub fn is_enabled(&self) -> bool {
|
||||
self.inner.is_some()
|
||||
}
|
||||
|
||||
/// Returns a reference to the inner `NetworkBehaviour`.
|
||||
pub fn as_ref(&self) -> Option<&TBehaviour> {
|
||||
self.inner.as_ref()
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the inner `NetworkBehaviour`.
|
||||
pub fn as_mut(&mut self) -> Option<&mut TBehaviour> {
|
||||
self.inner.as_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl<TBehaviour> From<Option<TBehaviour>> for Toggle<TBehaviour> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user