pub struct TetherRecordUtil { /* private fields */ }Implementations§
Source§impl TetherRecordUtil
impl TetherRecordUtil
Sourcepub fn new(options: RecordOptions) -> Self
pub fn new(options: RecordOptions) -> Self
Examples found in repository?
examples/api.rs (line 138)
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
fn demo_record() {
let mut tether_agent = TetherAgentOptionsBuilder::new("demoPlayback")
.build()
.expect("failed to init/connect Tether Agent");
let options = RecordOptions {
file_override_path: None,
file_base_path: "./".into(),
file_base_name: "recording".into(),
file_no_timestamp: false,
topic: "#".into(),
timing_nonzero_start: false,
timing_delay: None,
timing_duration: None,
ignore_ctrl_c: true, // this is important for programmatic use
};
let recorder = TetherRecordUtil::new(options);
let stop_request_tx = recorder.get_stop_tx();
let start_time = SystemTime::now();
let handles = vec![
spawn(move || {
let mut time_to_end = false;
while !time_to_end {
if let Ok(elapsed) = start_time.elapsed() {
if elapsed > std::time::Duration::from_secs(3) {
println!("Time to stop! {}s elapsed", elapsed.as_secs());
stop_request_tx
.send(true)
.expect("failed to send stop request via channel");
time_to_end = true;
}
}
}
println!("Recording should have stopped now; wait 4 more seconds...");
std::thread::sleep(std::time::Duration::from_secs(4));
println!("...Bye");
}),
spawn(move || {
recorder.start_recording(&mut tether_agent);
}),
];
for handle in handles {
handle.join().expect("RECORDER: failed to join handle");
}
}Sourcepub fn get_stop_tx(&self) -> Sender<bool>
pub fn get_stop_tx(&self) -> Sender<bool>
Examples found in repository?
examples/api.rs (line 139)
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
fn demo_record() {
let mut tether_agent = TetherAgentOptionsBuilder::new("demoPlayback")
.build()
.expect("failed to init/connect Tether Agent");
let options = RecordOptions {
file_override_path: None,
file_base_path: "./".into(),
file_base_name: "recording".into(),
file_no_timestamp: false,
topic: "#".into(),
timing_nonzero_start: false,
timing_delay: None,
timing_duration: None,
ignore_ctrl_c: true, // this is important for programmatic use
};
let recorder = TetherRecordUtil::new(options);
let stop_request_tx = recorder.get_stop_tx();
let start_time = SystemTime::now();
let handles = vec![
spawn(move || {
let mut time_to_end = false;
while !time_to_end {
if let Ok(elapsed) = start_time.elapsed() {
if elapsed > std::time::Duration::from_secs(3) {
println!("Time to stop! {}s elapsed", elapsed.as_secs());
stop_request_tx
.send(true)
.expect("failed to send stop request via channel");
time_to_end = true;
}
}
}
println!("Recording should have stopped now; wait 4 more seconds...");
std::thread::sleep(std::time::Duration::from_secs(4));
println!("...Bye");
}),
spawn(move || {
recorder.start_recording(&mut tether_agent);
}),
];
for handle in handles {
handle.join().expect("RECORDER: failed to join handle");
}
}Sourcepub fn start_recording(&self, tether_agent: &mut TetherAgent)
pub fn start_recording(&self, tether_agent: &mut TetherAgent)
Examples found in repository?
examples/api.rs (line 161)
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
fn demo_record() {
let mut tether_agent = TetherAgentOptionsBuilder::new("demoPlayback")
.build()
.expect("failed to init/connect Tether Agent");
let options = RecordOptions {
file_override_path: None,
file_base_path: "./".into(),
file_base_name: "recording".into(),
file_no_timestamp: false,
topic: "#".into(),
timing_nonzero_start: false,
timing_delay: None,
timing_duration: None,
ignore_ctrl_c: true, // this is important for programmatic use
};
let recorder = TetherRecordUtil::new(options);
let stop_request_tx = recorder.get_stop_tx();
let start_time = SystemTime::now();
let handles = vec![
spawn(move || {
let mut time_to_end = false;
while !time_to_end {
if let Ok(elapsed) = start_time.elapsed() {
if elapsed > std::time::Duration::from_secs(3) {
println!("Time to stop! {}s elapsed", elapsed.as_secs());
stop_request_tx
.send(true)
.expect("failed to send stop request via channel");
time_to_end = true;
}
}
}
println!("Recording should have stopped now; wait 4 more seconds...");
std::thread::sleep(std::time::Duration::from_secs(4));
println!("...Bye");
}),
spawn(move || {
recorder.start_recording(&mut tether_agent);
}),
];
for handle in handles {
handle.join().expect("RECORDER: failed to join handle");
}
}Auto Trait Implementations§
impl Freeze for TetherRecordUtil
impl RefUnwindSafe for TetherRecordUtil
impl Send for TetherRecordUtil
impl !Sync for TetherRecordUtil
impl Unpin for TetherRecordUtil
impl UnwindSafe for TetherRecordUtil
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more