Port

Trait Port 

Source
pub trait Port {
    // Provided methods
    fn get_name(&self) -> String { ... }
    fn get_port_flags(&self) -> PortFlags { ... }
}
Expand description

Ports are the means by which jack clients communicate with each other.

The port wrappers in easyjack have slightly confusing type definitions due to the behavior of the underlying JACK C API. The interface they expose is also much more “C” like than rust like.

Each of the Port structs defined implement the Port trait, which should be sufficient for use in many situations, however, occasionally, we may want to access pieces of data which are only available on specific types of ports.

Because the JACK C api handles all ports with a jack_port_t structure, we are limited in our ability to determine the exact properties of a port at compile time. For example, if you ask the JACK API to give you a port, by name, you cannot know all of the various properties of the port without additional inspection. This additional inspection will incur additional costs, so we have chosen to make all additional inspection optional.

This means that many of the easyjack API methods will return an UnknownPortHandle, and users of the API methods will have the option to attempt to promote this UnknownPortHandle to ports of different types. These attempts at conversion will perform additional inspection of the port’s flags (unless the unsafe versions are used)

One additional note about Port types. All of these port types are only handles to underlying ports (think of them as an index into a vector). All of these port types implement Copy. This means that a Port “handle” may become invalid if the port becomes invalid. Using a port after it has become invalid is undefined behavior and may cause all sorts of strange things to occur.

Provided Methods§

Source

fn get_name(&self) -> String

Gets the port’s assigned full name (including the client name and the colon)

Examples found in repository?
examples/connect.rs (line 76)
74    fn wait_and_shutdown(self) {
75        let (a, b, stat) = self.incoming.recv().unwrap();
76        let n1 = self.client.get_port_by_id(a).unwrap().get_name();
77        let n2 = self.client.get_port_by_id(b).unwrap().get_name();
78
79        match stat {
80            jack::PortConnectStatus::PortsConnected =>
81                println!("ports connected: {} and {}", n1, n2),
82
83            jack::PortConnectStatus::PortsDisconnected =>
84                println!("ports disconnected: {} and {}", n1, n2)
85        }
86    }
Source

fn get_port_flags(&self) -> PortFlags

Get the flags used to construct this port

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Port for UnknownPortHandle

Source§

impl<SampleType> Port for InputPortHandle<SampleType>

Source§

impl<SampleType> Port for OutputPortHandle<SampleType>