aya: Rename forget_link to take_link

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
pull/306/head
Dave Tucker 2 years ago
parent 79e06f2644
commit b2a6f00212

@ -128,11 +128,11 @@ impl CgroupSkb {
/// ///
/// The link will be detached on `Drop` and the caller is now responsible /// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime. /// for managing its lifetime.
pub fn forget_link( pub fn take_link(
&mut self, &mut self,
link_id: CgroupSkbLinkId, link_id: CgroupSkbLinkId,
) -> Result<OwnedLink<CgroupSkbLink>, ProgramError> { ) -> Result<OwnedLink<CgroupSkbLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?)) Ok(OwnedLink::new(self.data.take_link(link_id)?))
} }
/// Detaches the program. /// Detaches the program.

@ -107,11 +107,11 @@ impl CgroupSockAddr {
/// ///
/// The link will be detached on `Drop` and the caller is now responsible /// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime. /// for managing its lifetime.
pub fn forget_link( pub fn take_link(
&mut self, &mut self,
link_id: CgroupSockAddrLinkId, link_id: CgroupSockAddrLinkId,
) -> Result<OwnedLink<CgroupSockAddrLink>, ProgramError> { ) -> Result<OwnedLink<CgroupSockAddrLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?)) Ok(OwnedLink::new(self.data.take_link(link_id)?))
} }
/// Detaches the program. /// Detaches the program.

@ -103,11 +103,11 @@ impl CgroupSockopt {
/// ///
/// The link will be detached on `Drop` and the caller is now responsible /// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime. /// for managing its lifetime.
pub fn forget_link( pub fn take_link(
&mut self, &mut self,
link_id: CgroupSockoptLinkId, link_id: CgroupSockoptLinkId,
) -> Result<OwnedLink<CgroupSockoptLink>, ProgramError> { ) -> Result<OwnedLink<CgroupSockoptLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?)) Ok(OwnedLink::new(self.data.take_link(link_id)?))
} }
/// Detaches the program. /// Detaches the program.

@ -99,11 +99,11 @@ impl CgroupSysctl {
/// ///
/// The link will be detached on `Drop` and the caller is now responsible /// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime. /// for managing its lifetime.
pub fn forget_link( pub fn take_link(
&mut self, &mut self,
link_id: CgroupSysctlLinkId, link_id: CgroupSysctlLinkId,
) -> Result<OwnedLink<CgroupSysctlLink>, ProgramError> { ) -> Result<OwnedLink<CgroupSysctlLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?)) Ok(OwnedLink::new(self.data.take_link(link_id)?))
} }
/// Detaches the program. /// Detaches the program.

@ -154,11 +154,11 @@ impl Extension {
/// ///
/// The link will be detached on `Drop` and the caller is now responsible /// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime. /// for managing its lifetime.
pub fn forget_link( pub fn take_link(
&mut self, &mut self,
link_id: ExtensionLinkId, link_id: ExtensionLinkId,
) -> Result<OwnedLink<ExtensionLink>, ProgramError> { ) -> Result<OwnedLink<ExtensionLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?)) Ok(OwnedLink::new(self.data.take_link(link_id)?))
} }
} }

@ -80,11 +80,11 @@ impl FEntry {
/// ///
/// The link will be detached on `Drop` and the caller is now responsible /// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime. /// for managing its lifetime.
pub fn forget_link( pub fn take_link(
&mut self, &mut self,
link_id: FEntryLinkId, link_id: FEntryLinkId,
) -> Result<OwnedLink<FEntryLink>, ProgramError> { ) -> Result<OwnedLink<FEntryLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?)) Ok(OwnedLink::new(self.data.take_link(link_id)?))
} }
} }

@ -80,11 +80,11 @@ impl FExit {
/// ///
/// The link will be detached on `Drop` and the caller is now responsible /// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime. /// for managing its lifetime.
pub fn forget_link( pub fn take_link(
&mut self, &mut self,
link_id: FExitLinkId, link_id: FExitLinkId,
) -> Result<OwnedLink<FExitLink>, ProgramError> { ) -> Result<OwnedLink<FExitLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?)) Ok(OwnedLink::new(self.data.take_link(link_id)?))
} }
} }

@ -81,11 +81,11 @@ impl KProbe {
/// ///
/// The link will be detached on `Drop` and the caller is now responsible /// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime. /// for managing its lifetime.
pub fn forget_link( pub fn take_link(
&mut self, &mut self,
link_id: KProbeLinkId, link_id: KProbeLinkId,
) -> Result<OwnedLink<KProbeLink>, ProgramError> { ) -> Result<OwnedLink<KProbeLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?)) Ok(OwnedLink::new(self.data.take_link(link_id)?))
} }
} }

@ -86,11 +86,8 @@ impl LircMode2 {
/// ///
/// The link will be detached on `Drop` and the caller is now responsible /// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime. /// for managing its lifetime.
pub fn forget_link( pub fn take_link(&mut self, link_id: LircLinkId) -> Result<OwnedLink<LircLink>, ProgramError> {
&mut self, Ok(OwnedLink::new(self.data.take_link(link_id)?))
link_id: LircLinkId,
) -> Result<OwnedLink<LircLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?))
} }
/// Queries the lirc device for attached programs. /// Queries the lirc device for attached programs.

@ -85,8 +85,8 @@ impl Lsm {
/// ///
/// The link will be detached on `Drop` and the caller is now responsible /// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime. /// for managing its lifetime.
pub fn forget_link(&mut self, link_id: LsmLinkId) -> Result<OwnedLink<LsmLink>, ProgramError> { pub fn take_link(&mut self, link_id: LsmLinkId) -> Result<OwnedLink<LsmLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?)) Ok(OwnedLink::new(self.data.take_link(link_id)?))
} }
} }

@ -381,7 +381,7 @@ impl<T: Link> ProgramData<T> {
Ok(()) Ok(())
} }
pub(crate) fn forget_link(&mut self, link_id: T::Id) -> Result<T, ProgramError> { pub(crate) fn take_link(&mut self, link_id: T::Id) -> Result<T, ProgramError> {
self.links.forget(link_id) self.links.forget(link_id)
} }
} }
@ -556,7 +556,7 @@ macro_rules! impl_program_unload {
/// Unloads the program from the kernel. /// Unloads the program from the kernel.
/// ///
/// Links will be detached before unloading the program. Note /// Links will be detached before unloading the program. Note
/// that owned links obtained using `forget_link()` will not be /// that owned links obtained using `take_link()` will not be
/// detached. /// detached.
pub fn unload(&mut self) -> Result<(), ProgramError> { pub fn unload(&mut self) -> Result<(), ProgramError> {
unload_program(&mut self.data) unload_program(&mut self.data)

@ -182,10 +182,7 @@ impl PerfEvent {
/// ///
/// The link will be detached on `Drop` and the caller is now responsible /// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime. /// for managing its lifetime.
pub fn forget_link( pub fn take_link(&mut self, link_id: PerfLinkId) -> Result<OwnedLink<PerfLink>, ProgramError> {
&mut self, Ok(OwnedLink::new(self.data.take_link(link_id)?))
link_id: PerfLinkId,
) -> Result<OwnedLink<PerfLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?))
} }
} }

@ -64,11 +64,11 @@ impl RawTracePoint {
/// ///
/// The link will be detached on `Drop` and the caller is now responsible /// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime. /// for managing its lifetime.
pub fn forget_link( pub fn take_link(
&mut self, &mut self,
link_id: RawTracePointLinkId, link_id: RawTracePointLinkId,
) -> Result<OwnedLink<RawTracePointLink>, ProgramError> { ) -> Result<OwnedLink<RawTracePointLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?)) Ok(OwnedLink::new(self.data.take_link(link_id)?))
} }
} }

@ -78,11 +78,11 @@ impl SkLookup {
/// ///
/// The link will be detached on `Drop` and the caller is now responsible /// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime. /// for managing its lifetime.
pub fn forget_link( pub fn take_link(
&mut self, &mut self,
link_id: SkLookupLinkId, link_id: SkLookupLinkId,
) -> Result<OwnedLink<SkLookupLink>, ProgramError> { ) -> Result<OwnedLink<SkLookupLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?)) Ok(OwnedLink::new(self.data.take_link(link_id)?))
} }
/// Detaches the program. /// Detaches the program.

@ -100,11 +100,11 @@ impl SkMsg {
/// ///
/// The link will be detached on `Drop` and the caller is now responsible /// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime. /// for managing its lifetime.
pub fn forget_link( pub fn take_link(
&mut self, &mut self,
link_id: SkMsgLinkId, link_id: SkMsgLinkId,
) -> Result<OwnedLink<SkMsgLink>, ProgramError> { ) -> Result<OwnedLink<SkMsgLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?)) Ok(OwnedLink::new(self.data.take_link(link_id)?))
} }
} }

@ -95,11 +95,11 @@ impl SkSkb {
/// ///
/// The link will be detached on `Drop` and the caller is now responsible /// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime. /// for managing its lifetime.
pub fn forget_link( pub fn take_link(
&mut self, &mut self,
link_id: SkSkbLinkId, link_id: SkSkbLinkId,
) -> Result<OwnedLink<SkSkbLink>, ProgramError> { ) -> Result<OwnedLink<SkSkbLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?)) Ok(OwnedLink::new(self.data.take_link(link_id)?))
} }
} }

@ -87,11 +87,11 @@ impl SockOps {
/// ///
/// The link will be detached on `Drop` and the caller is now responsible /// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime. /// for managing its lifetime.
pub fn forget_link( pub fn take_link(
&mut self, &mut self,
link_id: SockOpsLinkId, link_id: SockOpsLinkId,
) -> Result<OwnedLink<SockOpsLink>, ProgramError> { ) -> Result<OwnedLink<SockOpsLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?)) Ok(OwnedLink::new(self.data.take_link(link_id)?))
} }
} }

@ -107,11 +107,11 @@ impl SocketFilter {
/// ///
/// The link will be detached on `Drop` and the caller is now responsible /// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime. /// for managing its lifetime.
pub fn forget_link( pub fn take_link(
&mut self, &mut self,
link_id: SocketFilterLinkId, link_id: SocketFilterLinkId,
) -> Result<OwnedLink<SocketFilterLink>, ProgramError> { ) -> Result<OwnedLink<SocketFilterLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?)) Ok(OwnedLink::new(self.data.take_link(link_id)?))
} }
} }

@ -146,11 +146,11 @@ impl SchedClassifier {
/// ///
/// The link will be detached on `Drop` and the caller is now responsible /// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime. /// for managing its lifetime.
pub fn forget_link( pub fn take_link(
&mut self, &mut self,
link_id: SchedClassifierLinkId, link_id: SchedClassifierLinkId,
) -> Result<OwnedLink<SchedClassifierLink>, ProgramError> { ) -> Result<OwnedLink<SchedClassifierLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?)) Ok(OwnedLink::new(self.data.take_link(link_id)?))
} }
} }

@ -83,11 +83,11 @@ impl BtfTracePoint {
/// ///
/// The link will be detached on `Drop` and the caller is now responsible /// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime. /// for managing its lifetime.
pub fn forget_link( pub fn take_link(
&mut self, &mut self,
link_id: BtfTracePointLinkId, link_id: BtfTracePointLinkId,
) -> Result<OwnedLink<BtfTracePointLink>, ProgramError> { ) -> Result<OwnedLink<BtfTracePointLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?)) Ok(OwnedLink::new(self.data.take_link(link_id)?))
} }
} }

@ -100,11 +100,11 @@ impl TracePoint {
/// ///
/// The link will be detached on `Drop` and the caller is now responsible /// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime. /// for managing its lifetime.
pub fn forget_link( pub fn take_link(
&mut self, &mut self,
link_id: TracePointLinkId, link_id: TracePointLinkId,
) -> Result<OwnedLink<TracePointLink>, ProgramError> { ) -> Result<OwnedLink<TracePointLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?)) Ok(OwnedLink::new(self.data.take_link(link_id)?))
} }
} }

@ -133,11 +133,11 @@ impl UProbe {
/// ///
/// The link will be detached on `Drop` and the caller is now responsible /// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime. /// for managing its lifetime.
pub fn forget_link( pub fn take_link(
&mut self, &mut self,
link_id: UProbeLinkId, link_id: UProbeLinkId,
) -> Result<OwnedLink<UProbeLink>, ProgramError> { ) -> Result<OwnedLink<UProbeLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?)) Ok(OwnedLink::new(self.data.take_link(link_id)?))
} }
} }

@ -138,8 +138,8 @@ impl Xdp {
/// ///
/// The link will be detached on `Drop` and the caller is now responsible /// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime. /// for managing its lifetime.
pub fn forget_link(&mut self, link_id: XdpLinkId) -> Result<OwnedLink<XdpLink>, ProgramError> { pub fn take_link(&mut self, link_id: XdpLinkId) -> Result<OwnedLink<XdpLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?)) Ok(OwnedLink::new(self.data.take_link(link_id)?))
} }
} }

@ -34,7 +34,7 @@ fn main() {
let link = dispatcher.attach("eth0", XdpFlags::default()).unwrap(); let link = dispatcher.attach("eth0", XdpFlags::default()).unwrap();
{ {
let link_owned = dispatcher.forget_link(link); let link_owned = dispatcher.take_link(link);
dispatcher.unload().unwrap(); dispatcher.unload().unwrap();

Loading…
Cancel
Save