rustduck-core 1.1.0

Safe typed TSDuck core bindings for rustduck
Documentation
//! Host-held exclusive endpoint binding leases.

use std::sync::Arc;

use super::inner::{MemoryInputInner, MemoryOutputInner};
use super::state::release;

/// A host-held exclusive input binding lease.
pub(crate) struct MemoryInputBinding {
    inner: Arc<MemoryInputInner>,
}

impl MemoryInputBinding {
    pub(super) fn new(inner: Arc<MemoryInputInner>) -> Self {
        Self { inner }
    }
    pub(crate) fn event_code(&self) -> u32 {
        self.inner.event_code()
    }
}

impl Drop for MemoryInputBinding {
    fn drop(&mut self) {
        release(self.inner.state());
    }
}

/// A host-held exclusive output binding lease.
pub(crate) struct MemoryOutputBinding {
    inner: Arc<MemoryOutputInner>,
}

impl MemoryOutputBinding {
    pub(super) fn new(inner: Arc<MemoryOutputInner>) -> Self {
        Self { inner }
    }
    pub(crate) fn event_code(&self) -> u32 {
        self.inner.event_code()
    }
}

impl Drop for MemoryOutputBinding {
    fn drop(&mut self) {
        release(self.inner.state());
    }
}