Examples: message handlers: invoke generic Message method from the concrete message

Generic methods for events, messages and queries can now be invoked from the concrete type.
This commit is contained in:
fengalin 2018-01-29 13:25:12 +01:00 committed by Sebastian Dröge
parent da924e5d4d
commit 21c687f256
14 changed files with 16 additions and 16 deletions

View file

@ -137,7 +137,7 @@ fn main_loop(pipeline: gst::Pipeline) -> Result<(), Error> {
MessageView::Error(err) => { MessageView::Error(err) => {
pipeline.set_state(gst::State::Null).into_result()?; pipeline.set_state(gst::State::Null).into_result()?;
Err(ErrorMessage { Err(ErrorMessage {
src: msg.get_src() src: err.get_src()
.map(|s| s.get_path_string()) .map(|s| s.get_path_string())
.unwrap_or_else(|| String::from("None")), .unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(), error: err.get_error().description().into(),

View file

@ -111,7 +111,7 @@ fn main_loop(pipeline: gst::Pipeline, appsrc: gst_app::AppSrc) -> Result<(), Err
MessageView::Error(err) => { MessageView::Error(err) => {
pipeline.set_state(gst::State::Null).into_result()?; pipeline.set_state(gst::State::Null).into_result()?;
Err(ErrorMessage { Err(ErrorMessage {
src: msg.get_src() src: err.get_src()
.map(|s| s.get_path_string()) .map(|s| s.get_path_string())
.unwrap_or_else(|| String::from("None")), .unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(), error: err.get_error().description().into(),

View file

@ -174,7 +174,7 @@ fn example_main() -> Result<(), Error> {
.map(Result::Err) .map(Result::Err)
.expect("error-details message without actual error"), .expect("error-details message without actual error"),
_ => Err(ErrorMessage { _ => Err(ErrorMessage {
src: msg.get_src() src: err.get_src()
.map(|s| s.get_path_string()) .map(|s| s.get_path_string())
.unwrap_or_else(|| String::from("None")), .unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(), error: err.get_error().description().into(),
@ -186,7 +186,7 @@ fn example_main() -> Result<(), Error> {
#[cfg(not(feature = "v1_10"))] #[cfg(not(feature = "v1_10"))]
{ {
Err(ErrorMessage { Err(ErrorMessage {
src: msg.get_src() src: err.get_src()
.map(|s| s.get_path_string()) .map(|s| s.get_path_string())
.unwrap_or_else(|| String::from("None")), .unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(), error: err.get_error().description().into(),
@ -199,7 +199,7 @@ fn example_main() -> Result<(), Error> {
MessageView::StateChanged(s) => { MessageView::StateChanged(s) => {
println!( println!(
"State changed from {:?}: {:?} -> {:?} ({:?})", "State changed from {:?}: {:?} -> {:?} ({:?})",
msg.get_src().map(|s| s.get_path_string()), s.get_src().map(|s| s.get_path_string()),
s.get_old(), s.get_old(),
s.get_current(), s.get_current(),
s.get_pending() s.get_pending()

View file

@ -45,7 +45,7 @@ fn example_main() {
MessageView::Error(err) => { MessageView::Error(err) => {
println!( println!(
"Error from {:?}: {} ({:?})", "Error from {:?}: {} ({:?})",
msg.get_src().map(|s| s.get_path_string()), err.get_src().map(|s| s.get_path_string()),
err.get_error(), err.get_error(),
err.get_debug() err.get_debug()
); );

View file

@ -89,7 +89,7 @@ fn create_ui(app: &gtk::Application) {
MessageView::Error(err) => { MessageView::Error(err) => {
println!( println!(
"Error from {:?}: {} ({:?})", "Error from {:?}: {} ({:?})",
msg.get_src().map(|s| s.get_path_string()), err.get_src().map(|s| s.get_path_string()),
err.get_error(), err.get_error(),
err.get_debug() err.get_debug()
); );

View file

@ -159,7 +159,7 @@ fn create_ui(app: &gtk::Application) {
MessageView::Error(err) => { MessageView::Error(err) => {
println!( println!(
"Error from {:?}: {} ({:?})", "Error from {:?}: {} ({:?})",
msg.get_src().map(|s| s.get_path_string()), err.get_src().map(|s| s.get_path_string()),
err.get_error(), err.get_error(),
err.get_debug() err.get_debug()
); );

View file

@ -39,7 +39,7 @@ fn example_main() {
MessageView::Error(err) => { MessageView::Error(err) => {
println!( println!(
"Error from {:?}: {} ({:?})", "Error from {:?}: {} ({:?})",
msg.get_src().map(|s| s.get_path_string()), err.get_src().map(|s| s.get_path_string()),
err.get_error(), err.get_error(),
err.get_debug() err.get_debug()
); );

View file

@ -34,7 +34,7 @@ fn example_main() {
MessageView::Error(err) => { MessageView::Error(err) => {
println!( println!(
"Error from {:?}: {} ({:?})", "Error from {:?}: {} ({:?})",
msg.get_src().map(|s| s.get_path_string()), err.get_src().map(|s| s.get_path_string()),
err.get_error(), err.get_error(),
err.get_debug() err.get_debug()
); );

View file

@ -61,7 +61,7 @@ fn example_main() {
MessageView::Error(err) => { MessageView::Error(err) => {
println!( println!(
"Error from {:?}: {} ({:?})", "Error from {:?}: {} ({:?})",
msg.get_src().map(|s| s.get_path_string()), err.get_src().map(|s| s.get_path_string()),
err.get_error(), err.get_error(),
err.get_debug() err.get_debug()
); );

View file

@ -76,7 +76,7 @@ fn example_main() {
MessageView::Error(err) => { MessageView::Error(err) => {
println!( println!(
"Error from {:?}: {} ({:?})", "Error from {:?}: {} ({:?})",
msg.get_src().map(|s| s.get_path_string()), err.get_src().map(|s| s.get_path_string()),
err.get_error(), err.get_error(),
err.get_debug() err.get_debug()
); );

View file

@ -73,7 +73,7 @@ fn example_main() {
MessageView::Error(err) => { MessageView::Error(err) => {
println!( println!(
"Error from {:?}: {} ({:?})", "Error from {:?}: {} ({:?})",
msg.get_src().map(|s| s.get_path_string()), err.get_src().map(|s| s.get_path_string()),
err.get_error(), err.get_error(),
err.get_debug() err.get_debug()
); );

View file

@ -71,7 +71,7 @@ fn example_main() -> Result<(), Error> {
MessageView::Eos(..) => break, MessageView::Eos(..) => break,
MessageView::Error(err) => { MessageView::Error(err) => {
Err(ErrorMessage { Err(ErrorMessage {
src: msg.get_src() src: err.get_src()
.map(|s| s.get_path_string()) .map(|s| s.get_path_string())
.unwrap_or_else(|| String::from("None")), .unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(), error: err.get_error().description().into(),

View file

@ -63,7 +63,7 @@ fn example_main() {
MessageView::Error(err) => { MessageView::Error(err) => {
println!( println!(
"Error from {:?}: {} ({:?})", "Error from {:?}: {} ({:?})",
msg.get_src().map(|s| s.get_path_string()), err.get_src().map(|s| s.get_path_string()),
err.get_error(), err.get_error(),
err.get_debug() err.get_debug()
); );

View file

@ -41,7 +41,7 @@ fn example_main() {
MessageView::Error(err) => { MessageView::Error(err) => {
println!( println!(
"Error from {:?}: {} ({:?})", "Error from {:?}: {} ({:?})",
msg.get_src().map(|s| s.get_path_string()), err.get_src().map(|s| s.get_path_string()),
err.get_error(), err.get_error(),
err.get_debug() err.get_debug()
); );