1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use crate::host::subprogram_id::*;
use crate::host::filter::*;
use serde::*;
///
/// A stream target describes where the output of a particular stream should be sent
///
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
#[derive(Serialize, Deserialize)]
pub enum StreamTarget {
/// Discard any output sent to this stream
None,
/// Send output for this stream to the default target for the scene (or defer until a default target is set)
Any,
/// Send the stream to the input of the specified program
Program(SubProgramId),
/// Send the stream to a subprogram after running through a filter
///
/// Note that this cannot be combined with `StreamSource::Filtered()`.
///
/// When connecting this is the equivalent of using `StreamSource::Filtered(filter_handle)` with
/// `StreamTarget::Program(program_id)`.
///
/// This can be combined with `StreamSource::Program()` can filter only the output of a single
/// program. It is also useful as a target for the `StreamContext::send()` call for deliberately
/// filtering the output of an existing program.
Filtered(FilterHandle, SubProgramId),
}
impl StreamTarget {
///
/// The program ID that this target will connect to
///
pub fn target_sub_program(&self) -> Option<SubProgramId> {
match self {
StreamTarget::None | StreamTarget::Any => None,
StreamTarget::Program(prog_id) | StreamTarget::Filtered(_, prog_id) => Some(*prog_id),
}
}
}
impl From<SubProgramId> for StreamTarget {
#[inline]
fn from(program: SubProgramId) -> StreamTarget {
StreamTarget::Program(program)
}
}
impl<'a> From<&'a SubProgramId> for StreamTarget {
#[inline]
fn from(program: &'a SubProgramId) -> StreamTarget {
StreamTarget::Program(*program)
}
}
/// '()' can be used in place of StreamTarget::Any
impl From<()> for StreamTarget {
#[inline]
fn from(_: ()) -> StreamTarget {
StreamTarget::Any
}
}