forked from mirrors/gstreamer-rs
Update for glib changes in glib::Value handling
This commit is contained in:
parent
0207e41160
commit
ba719ac90c
11 changed files with 108 additions and 144 deletions
|
@ -431,7 +431,7 @@ impl App {
|
||||||
{
|
{
|
||||||
let context = context.get_mut().unwrap();
|
let context = context.get_mut().unwrap();
|
||||||
let s = context.get_mut_structure();
|
let s = context.get_mut_structure();
|
||||||
s.set_value("context", gl_context.to_send_value());
|
s.set("context", &gl_context);
|
||||||
}
|
}
|
||||||
el.set_context(&context);
|
el.set_context(&context);
|
||||||
}
|
}
|
||||||
|
@ -537,9 +537,9 @@ impl App {
|
||||||
|
|
||||||
sink.set_property("sink", &appsink)?;
|
sink.set_property("sink", &appsink)?;
|
||||||
|
|
||||||
appsink.set_property("enable-last-sample", &false.to_value())?;
|
appsink.set_property("enable-last-sample", &false)?;
|
||||||
appsink.set_property("emit-signals", &false.to_value())?;
|
appsink.set_property("emit-signals", &false)?;
|
||||||
appsink.set_property("max-buffers", &1u32.to_value())?;
|
appsink.set_property("max-buffers", &1u32)?;
|
||||||
|
|
||||||
let caps = gst::Caps::builder("video/x-raw")
|
let caps = gst::Caps::builder("video/x-raw")
|
||||||
.features(&[&gst_gl::CAPS_FEATURE_MEMORY_GL_MEMORY])
|
.features(&[&gst_gl::CAPS_FEATURE_MEMORY_GL_MEMORY])
|
||||||
|
|
|
@ -34,9 +34,7 @@ fn create_ui(app: >k::Application) {
|
||||||
// video frames to our texture (if they are not already in the GPU). Now we tell the OpenGL-sink
|
// video frames to our texture (if they are not already in the GPU). Now we tell the OpenGL-sink
|
||||||
// about our gtkglsink element, form where it will retrieve the OpenGL texture to fill.
|
// about our gtkglsink element, form where it will retrieve the OpenGL texture to fill.
|
||||||
let glsinkbin = gst::ElementFactory::make("glsinkbin", None).unwrap();
|
let glsinkbin = gst::ElementFactory::make("glsinkbin", None).unwrap();
|
||||||
glsinkbin
|
glsinkbin.set_property("sink", >kglsink).unwrap();
|
||||||
.set_property("sink", >kglsink.to_value())
|
|
||||||
.unwrap();
|
|
||||||
// The gtkglsink creates the gtk widget for us. This is accessible through a property.
|
// The gtkglsink creates the gtk widget for us. This is accessible through a property.
|
||||||
// So we get it and use it later to add it to our gui.
|
// So we get it and use it later to add it to our gui.
|
||||||
let widget = gtkglsink.get_property("widget").unwrap();
|
let widget = gtkglsink.get_property("widget").unwrap();
|
||||||
|
|
|
@ -29,9 +29,7 @@ fn example_main() {
|
||||||
|
|
||||||
// Create a new playbin element, and tell it what uri to play back.
|
// Create a new playbin element, and tell it what uri to play back.
|
||||||
let playbin = gst::ElementFactory::make("playbin", None).unwrap();
|
let playbin = gst::ElementFactory::make("playbin", None).unwrap();
|
||||||
playbin
|
playbin.set_property("uri", &uri).unwrap();
|
||||||
.set_property("uri", &glib::Value::from(uri))
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
// For flags handling
|
// For flags handling
|
||||||
// With flags, one can configure playbin's behavior such as whether it
|
// With flags, one can configure playbin's behavior such as whether it
|
||||||
|
@ -79,10 +77,7 @@ fn example_main() {
|
||||||
// application is via properties, signals or action signals (or custom messages, events, queries).
|
// application is via properties, signals or action signals (or custom messages, events, queries).
|
||||||
// So what the following code does, is essentially asking playbin to tell us its already
|
// So what the following code does, is essentially asking playbin to tell us its already
|
||||||
// internally stored tag list for this stream index.
|
// internally stored tag list for this stream index.
|
||||||
let tags = playbin
|
let tags = playbin.emit("get-audio-tags", &[&idx]).unwrap().unwrap();
|
||||||
.emit("get-audio-tags", &[&idx.to_value()])
|
|
||||||
.unwrap()
|
|
||||||
.unwrap();
|
|
||||||
let tags = tags.get::<gst::TagList>().expect("tags").unwrap();
|
let tags = tags.get::<gst::TagList>().expect("tags").unwrap();
|
||||||
|
|
||||||
if let Some(artist) = tags.get::<gst::tags::Artist>() {
|
if let Some(artist) = tags.get::<gst::tags::Artist>() {
|
||||||
|
|
|
@ -83,12 +83,15 @@ fn connect_rtpbin_srcpad(src_pad: &gst::Pad, sink: &gst::Element) -> Result<(),
|
||||||
fn make_fec_decoder(rtpbin: &gst::Element, sess_id: u32) -> Result<gst::Element, Error> {
|
fn make_fec_decoder(rtpbin: &gst::Element, sess_id: u32) -> Result<gst::Element, Error> {
|
||||||
let fecdec = make_element("rtpulpfecdec", None)?;
|
let fecdec = make_element("rtpulpfecdec", None)?;
|
||||||
let internal_storage = rtpbin
|
let internal_storage = rtpbin
|
||||||
.emit("get-internal-storage", &[&sess_id.to_value()])
|
.emit("get-internal-storage", &[&sess_id])
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap();
|
.unwrap()
|
||||||
|
.get::<glib::Object>()
|
||||||
|
.unwrap()
|
||||||
|
.expect("No internal-storage");
|
||||||
|
|
||||||
fecdec.set_property("storage", &internal_storage.to_value())?;
|
fecdec.set_property("storage", &internal_storage)?;
|
||||||
fecdec.set_property("pt", &100u32.to_value())?;
|
fecdec.set_property("pt", &100u32)?;
|
||||||
|
|
||||||
Ok(fecdec)
|
Ok(fecdec)
|
||||||
}
|
}
|
||||||
|
@ -130,7 +133,7 @@ fn example_main() -> Result<(), Error> {
|
||||||
|
|
||||||
pipeline.add_many(&[&enc, &mux, &sink])?;
|
pipeline.add_many(&[&enc, &mux, &sink])?;
|
||||||
gst::Element::link_many(&[&filter, &enc, &mux, &sink])?;
|
gst::Element::link_many(&[&filter, &enc, &mux, &sink])?;
|
||||||
sink.set_property("location", &"out.mkv".to_value())?;
|
sink.set_property("location", &"out.mkv")?;
|
||||||
enc.set_property_from_str("tune", "zerolatency");
|
enc.set_property_from_str("tune", "zerolatency");
|
||||||
eprintln!("Recording to out.mkv");
|
eprintln!("Recording to out.mkv");
|
||||||
}
|
}
|
||||||
|
@ -144,9 +147,7 @@ fn example_main() -> Result<(), Error> {
|
||||||
.get::<gst::Element>()
|
.get::<gst::Element>()
|
||||||
.expect("rtpbin \"new-storage\" signal values[1]")
|
.expect("rtpbin \"new-storage\" signal values[1]")
|
||||||
.expect("rtpbin \"new-storage\" signal values[1]: no `Element`");
|
.expect("rtpbin \"new-storage\" signal values[1]: no `Element`");
|
||||||
storage
|
storage.set_property("size-time", &250_000_000u64).unwrap();
|
||||||
.set_property("size-time", &250_000_000u64.to_value())
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
None
|
None
|
||||||
})?;
|
})?;
|
||||||
|
@ -234,11 +235,11 @@ fn example_main() -> Result<(), Error> {
|
||||||
let video_caps =
|
let video_caps =
|
||||||
gst::Caps::new_simple("video/x-raw", &[("width", &1920i32), ("height", &1080i32)]);
|
gst::Caps::new_simple("video/x-raw", &[("width", &1920i32), ("height", &1080i32)]);
|
||||||
|
|
||||||
src.set_property("address", &"127.0.0.1".to_value())?;
|
src.set_property("address", &"127.0.0.1")?;
|
||||||
src.set_property("caps", &rtp_caps.to_value())?;
|
src.set_property("caps", &rtp_caps)?;
|
||||||
netsim.set_property("drop-probability", &drop_probability.to_value())?;
|
netsim.set_property("drop-probability", &drop_probability)?;
|
||||||
rtpbin.set_property("do-lost", &true.to_value())?;
|
rtpbin.set_property("do-lost", &true)?;
|
||||||
filter.set_property("caps", &video_caps.to_value())?;
|
filter.set_property("caps", &video_caps)?;
|
||||||
|
|
||||||
let bus = pipeline
|
let bus = pipeline
|
||||||
.get_bus()
|
.get_bus()
|
||||||
|
|
|
@ -70,9 +70,9 @@ fn connect_decodebin_pad(src_pad: &gst::Pad, sink: &gst::Element) -> Result<(),
|
||||||
fn make_fec_encoder(fec_percentage: u32) -> Result<gst::Element, Error> {
|
fn make_fec_encoder(fec_percentage: u32) -> Result<gst::Element, Error> {
|
||||||
let fecenc = make_element("rtpulpfecenc", None)?;
|
let fecenc = make_element("rtpulpfecenc", None)?;
|
||||||
|
|
||||||
fecenc.set_property("pt", &100u32.to_value())?;
|
fecenc.set_property("pt", &100u32)?;
|
||||||
fecenc.set_property("multipacket", &true.to_value())?;
|
fecenc.set_property("multipacket", &true)?;
|
||||||
fecenc.set_property("percentage", &fec_percentage.to_value())?;
|
fecenc.set_property("percentage", &fec_percentage)?;
|
||||||
|
|
||||||
Ok(fecenc)
|
Ok(fecenc)
|
||||||
}
|
}
|
||||||
|
@ -151,16 +151,16 @@ fn example_main() -> Result<(), Error> {
|
||||||
let video_caps = gst::Caps::new_simple("video/x-raw", &[]);
|
let video_caps = gst::Caps::new_simple("video/x-raw", &[]);
|
||||||
|
|
||||||
src.set_property_from_str("pattern", "ball");
|
src.set_property_from_str("pattern", "ball");
|
||||||
sink.set_property("host", &"127.0.0.1".to_value())?;
|
sink.set_property("host", &"127.0.0.1")?;
|
||||||
sink.set_property("sync", &true.to_value())?;
|
sink.set_property("sync", &true)?;
|
||||||
enc.set_property("keyframe-max-dist", &30i32.to_value())?;
|
enc.set_property("keyframe-max-dist", &30i32)?;
|
||||||
enc.set_property("threads", &12i32.to_value())?;
|
enc.set_property("threads", &12i32)?;
|
||||||
enc.set_property("cpu-used", &(-16i32).to_value())?;
|
enc.set_property("cpu-used", &(-16i32))?;
|
||||||
enc.set_property("deadline", &1i64.to_value())?;
|
enc.set_property("deadline", &1i64)?;
|
||||||
enc.set_property_from_str("error-resilient", "default");
|
enc.set_property_from_str("error-resilient", "default");
|
||||||
src.set_property("expose-all-streams", &false.to_value())?;
|
src.set_property("expose-all-streams", &false)?;
|
||||||
src.set_property("caps", &video_caps.to_value())?;
|
src.set_property("caps", &video_caps)?;
|
||||||
src.set_property("uri", &uri.to_value())?;
|
src.set_property("uri", &uri)?;
|
||||||
|
|
||||||
let bus = pipeline
|
let bus = pipeline
|
||||||
.get_bus()
|
.get_bus()
|
||||||
|
|
|
@ -31,8 +31,7 @@ fn example_main() {
|
||||||
let src = gst::ElementFactory::make("filesrc", None).unwrap();
|
let src = gst::ElementFactory::make("filesrc", None).unwrap();
|
||||||
let decodebin = gst::ElementFactory::make("decodebin", None).unwrap();
|
let decodebin = gst::ElementFactory::make("decodebin", None).unwrap();
|
||||||
|
|
||||||
src.set_property("location", &glib::Value::from(uri))
|
src.set_property("location", &uri).unwrap();
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
pipeline.add_many(&[&src, &decodebin]).unwrap();
|
pipeline.add_many(&[&src, &decodebin]).unwrap();
|
||||||
gst::Element::link_many(&[&src, &decodebin]).unwrap();
|
gst::Element::link_many(&[&src, &decodebin]).unwrap();
|
||||||
|
|
|
@ -72,13 +72,13 @@ fn example_main() -> Result<(), Error> {
|
||||||
.expect("setting location property failed");
|
.expect("setting location property failed");
|
||||||
// Increase the queue capacity to 100MB to avoid a stalling pipeline
|
// Increase the queue capacity to 100MB to avoid a stalling pipeline
|
||||||
queue
|
queue
|
||||||
.set_property("max-size-buffers", &0u32.to_value())
|
.set_property("max-size-buffers", &0u32)
|
||||||
.expect("changing capacity of multiqueue failed");
|
.expect("changing capacity of multiqueue failed");
|
||||||
queue
|
queue
|
||||||
.set_property("max-size-time", &0u64.to_value())
|
.set_property("max-size-time", &0u64)
|
||||||
.expect("changing capacity of multiqueue failed");
|
.expect("changing capacity of multiqueue failed");
|
||||||
queue
|
queue
|
||||||
.set_property("max-size-bytes", &(1024u32 * 1024 * 100).to_value())
|
.set_property("max-size-bytes", &(1024u32 * 1024 * 100))
|
||||||
.expect("changing capacity of multiqueue failed");
|
.expect("changing capacity of multiqueue failed");
|
||||||
|
|
||||||
pipeline
|
pipeline
|
||||||
|
|
|
@ -374,13 +374,21 @@ impl TagListRef {
|
||||||
where
|
where
|
||||||
T: ToSendValue,
|
T: ToSendValue,
|
||||||
{
|
{
|
||||||
unsafe {
|
|
||||||
let v = value.to_send_value();
|
let v = value.to_send_value();
|
||||||
|
self.add_value(tag_name, &v, mode)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn add_value(
|
||||||
|
&mut self,
|
||||||
|
tag_name: &str,
|
||||||
|
value: &glib::SendValue,
|
||||||
|
mode: TagMergeMode,
|
||||||
|
) -> Result<(), TagError> {
|
||||||
|
unsafe {
|
||||||
let tag_name = tag_name.to_glib_none();
|
let tag_name = tag_name.to_glib_none();
|
||||||
|
|
||||||
let tag_type: glib::Type = from_glib(gst_sys::gst_tag_get_type(tag_name.0));
|
let tag_type: glib::Type = from_glib(gst_sys::gst_tag_get_type(tag_name.0));
|
||||||
if tag_type != v.type_() {
|
if tag_type != value.type_() {
|
||||||
return Err(TagError::TypeMismatch);
|
return Err(TagError::TypeMismatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,7 +396,7 @@ impl TagListRef {
|
||||||
self.as_mut_ptr(),
|
self.as_mut_ptr(),
|
||||||
mode.to_glib(),
|
mode.to_glib(),
|
||||||
tag_name.0,
|
tag_name.0,
|
||||||
v.to_glib_none().0,
|
value.to_glib_none().0,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -224,7 +224,7 @@ impl<'de, 'a> Visitor<'de> for TagValuesVisitor<'a> {
|
||||||
match tag_value {
|
match tag_value {
|
||||||
Some(tag_value) => self
|
Some(tag_value) => self
|
||||||
.1
|
.1
|
||||||
.add_generic(self.0, &tag_value, TagMergeMode::Append)
|
.add_value(self.0, &tag_value, TagMergeMode::Append)
|
||||||
.map_err(|_| {
|
.map_err(|_| {
|
||||||
de::Error::custom(format!("wrong value type for `Tag` {}", self.0))
|
de::Error::custom(format!("wrong value type for `Tag` {}", self.0))
|
||||||
})?,
|
})?,
|
||||||
|
|
|
@ -586,6 +586,12 @@ impl<'a> Array<'a> {
|
||||||
Array(values.iter().map(|v| v.to_send_value()).collect())
|
Array(values.iter().map(|v| v.to_send_value()).collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn from_borrowed<T: AsRef<[glib::SendValue]>>(values: &'a T) -> Self {
|
||||||
|
assert_initialized_main_thread!();
|
||||||
|
|
||||||
|
Array(Cow::Borrowed(values.as_ref()))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn from_owned(values: Vec<glib::SendValue>) -> Self {
|
pub fn from_owned(values: Vec<glib::SendValue>) -> Self {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
|
|
||||||
|
@ -664,6 +670,12 @@ impl<'a> List<'a> {
|
||||||
List(values.iter().map(|v| v.to_send_value()).collect())
|
List(values.iter().map(|v| v.to_send_value()).collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn from_borrowed<T: AsRef<[glib::SendValue]>>(values: &'a T) -> Self {
|
||||||
|
assert_initialized_main_thread!();
|
||||||
|
|
||||||
|
List(Cow::Borrowed(values.as_ref()))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn from_owned(values: Vec<glib::SendValue>) -> Self {
|
pub fn from_owned(values: Vec<glib::SendValue>) -> Self {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
|
|
||||||
|
|
|
@ -364,8 +364,6 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_serialize_collections() {
|
fn test_serialize_collections() {
|
||||||
use glib::value::ToValue;
|
|
||||||
|
|
||||||
use Fraction;
|
use Fraction;
|
||||||
use List;
|
use List;
|
||||||
|
|
||||||
|
@ -375,33 +373,20 @@ mod tests {
|
||||||
pretty_config.new_line = "".to_string();
|
pretty_config.new_line = "".to_string();
|
||||||
|
|
||||||
// Array
|
// Array
|
||||||
let value_13 = Fraction::new(1, 3).to_value();
|
let value_13 = Fraction::new(1, 3);
|
||||||
let send_value_13 = value_13.try_into_send_value::<Fraction>().unwrap();
|
let value_12 = Fraction::new(1, 2);
|
||||||
|
let value_str = "test str";
|
||||||
let value_12 = Fraction::new(1, 2).to_value();
|
let value_str_none: Option<&str> = None;
|
||||||
let send_value_12 = value_12.try_into_send_value::<Fraction>().unwrap();
|
let value_date = Date::new_dmy(19, DateMonth::August, 2019);
|
||||||
|
let value_date_none: Option<Date> = None;
|
||||||
let value_str = "test str".to_value();
|
|
||||||
let send_value_str = value_str.try_into_send_value::<String>().unwrap();
|
|
||||||
|
|
||||||
let str_none: Option<&str> = None;
|
|
||||||
let value_str_none = str_none.to_value();
|
|
||||||
let send_value_str_none = value_str_none.try_into_send_value::<String>().unwrap();
|
|
||||||
|
|
||||||
let value_date = Date::new_dmy(19, DateMonth::August, 2019).to_value();
|
|
||||||
let send_value_date = value_date.try_into_send_value::<Date>().unwrap();
|
|
||||||
|
|
||||||
let date_none: Option<Date> = None;
|
|
||||||
let value_date_none = date_none.to_value();
|
|
||||||
let send_value_date_none = value_date_none.try_into_send_value::<Date>().unwrap();
|
|
||||||
|
|
||||||
let array = Array::new(&[
|
let array = Array::new(&[
|
||||||
&send_value_13,
|
&value_13,
|
||||||
&send_value_12,
|
&value_12,
|
||||||
&send_value_str,
|
&value_str,
|
||||||
&send_value_str_none,
|
&value_str_none,
|
||||||
&send_value_date,
|
&value_date,
|
||||||
&send_value_date_none,
|
&value_date_none,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let res = ron::ser::to_string_pretty(&array, pretty_config.clone());
|
let res = ron::ser::to_string_pretty(&array, pretty_config.clone());
|
||||||
|
@ -428,33 +413,18 @@ mod tests {
|
||||||
);
|
);
|
||||||
|
|
||||||
// List
|
// List
|
||||||
let value_12 = Fraction::new(1, 2).to_value();
|
let value_12 = Fraction::new(1, 2);
|
||||||
let send_value_12 = value_12.try_into_send_value::<Fraction>().unwrap();
|
let value_str = "test str";
|
||||||
|
let value_str_none: Option<&str> = None;
|
||||||
let value_str = "test str".to_value();
|
let value_date_time = DateTime::new(2f32, 2019, 8, 19, 13, 34, 42f64).unwrap();
|
||||||
let send_value_str = value_str.try_into_send_value::<String>().unwrap();
|
let value_date_time_none: Option<DateTime> = None;
|
||||||
|
|
||||||
let str_none: Option<&str> = None;
|
|
||||||
let value_str_none = str_none.to_value();
|
|
||||||
let send_value_str_none = value_str_none.try_into_send_value::<String>().unwrap();
|
|
||||||
|
|
||||||
let value_date_time = DateTime::new(2f32, 2019, 8, 19, 13, 34, 42f64)
|
|
||||||
.unwrap()
|
|
||||||
.to_value();
|
|
||||||
let send_value_date_time = value_date_time.try_into_send_value::<DateTime>().unwrap();
|
|
||||||
|
|
||||||
let date_time_none: Option<DateTime> = None;
|
|
||||||
let value_date_time_none = date_time_none.to_value();
|
|
||||||
let send_value_date_time_none = value_date_time_none
|
|
||||||
.try_into_send_value::<DateTime>()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let list = List::new(&[
|
let list = List::new(&[
|
||||||
&send_value_12,
|
&value_12,
|
||||||
&send_value_str,
|
&value_str,
|
||||||
&send_value_str_none,
|
&value_str_none,
|
||||||
&send_value_date_time,
|
&value_date_time,
|
||||||
&send_value_date_time_none,
|
&value_date_time_none,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let res = ron::ser::to_string_pretty(&list, pretty_config);
|
let res = ron::ser::to_string_pretty(&list, pretty_config);
|
||||||
|
@ -664,32 +634,23 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_serde_roundtrip_collection() {
|
fn test_serde_roundtrip_collection() {
|
||||||
use glib::value::ToValue;
|
|
||||||
|
|
||||||
::init().unwrap();
|
::init().unwrap();
|
||||||
|
|
||||||
// Array
|
// Array
|
||||||
let value_13 = Fraction::new(1, 3).to_value();
|
let value_13 = Fraction::new(1, 3);
|
||||||
let send_value_13 = value_13.try_into_send_value::<Fraction>().unwrap();
|
let value_12 = Fraction::new(1, 2);
|
||||||
let value_12 = Fraction::new(1, 2).to_value();
|
let value_str = "test str";
|
||||||
let send_value_12 = value_12.try_into_send_value::<Fraction>().unwrap();
|
let value_str_none: Option<&str> = None;
|
||||||
let value_str = "test str".to_value();
|
let value_date = Date::new_dmy(19, DateMonth::August, 2019);
|
||||||
let send_value_str = value_str.try_into_send_value::<String>().unwrap();
|
let value_date_none: Option<Date> = None;
|
||||||
let str_none: Option<&str> = None;
|
|
||||||
let value_str_none = str_none.to_value();
|
|
||||||
let send_value_str_none = value_str_none.try_into_send_value::<String>().unwrap();
|
|
||||||
let value_date = Date::new_dmy(19, DateMonth::August, 2019).to_value();
|
|
||||||
let send_value_date = value_date.try_into_send_value::<Date>().unwrap();
|
|
||||||
let date_none: Option<Date> = None;
|
|
||||||
let value_date_none = date_none.to_value();
|
|
||||||
let send_value_date_none = value_date_none.try_into_send_value::<Date>().unwrap();
|
|
||||||
let array = Array::new(&[
|
let array = Array::new(&[
|
||||||
&send_value_13,
|
&value_13,
|
||||||
&send_value_12,
|
&value_12,
|
||||||
&send_value_str,
|
&value_str,
|
||||||
&send_value_str_none,
|
&value_str_none,
|
||||||
&send_value_date,
|
&value_date,
|
||||||
&send_value_date_none,
|
&value_date_none,
|
||||||
]);
|
]);
|
||||||
let array_ser = ron::ser::to_string(&array).unwrap();
|
let array_ser = ron::ser::to_string(&array).unwrap();
|
||||||
|
|
||||||
|
@ -723,28 +684,18 @@ mod tests {
|
||||||
assert!(slice[5].get::<Date>().expect("slice[5]").is_none());
|
assert!(slice[5].get::<Date>().expect("slice[5]").is_none());
|
||||||
|
|
||||||
// List
|
// List
|
||||||
let value_12 = Fraction::new(1, 2).to_value();
|
let value_12 = Fraction::new(1, 2);
|
||||||
let send_value_12 = value_12.try_into_send_value::<Fraction>().unwrap();
|
let value_str = "test str";
|
||||||
let value_str = "test str".to_value();
|
let value_str_none: Option<&str> = None;
|
||||||
let send_value_str = value_str.try_into_send_value::<String>().unwrap();
|
let value_date_time = DateTime::new(2f32, 2019, 8, 19, 13, 34, 42f64).unwrap();
|
||||||
let str_none: Option<&str> = None;
|
let value_date_time_none: Option<DateTime> = None;
|
||||||
let value_str_none = str_none.to_value();
|
|
||||||
let send_value_str_none = value_str_none.try_into_send_value::<String>().unwrap();
|
|
||||||
let value_date_time = DateTime::new(2f32, 2019, 8, 19, 13, 34, 42f64)
|
|
||||||
.unwrap()
|
|
||||||
.to_value();
|
|
||||||
let send_value_date_time = value_date_time.try_into_send_value::<DateTime>().unwrap();
|
|
||||||
let date_time_none: Option<DateTime> = None;
|
|
||||||
let value_date_time_none = date_time_none.to_value();
|
|
||||||
let send_value_date_time_none = value_date_time_none
|
|
||||||
.try_into_send_value::<DateTime>()
|
|
||||||
.unwrap();
|
|
||||||
let list = List::new(&[
|
let list = List::new(&[
|
||||||
&send_value_12,
|
&value_12,
|
||||||
&send_value_str,
|
&value_str,
|
||||||
&send_value_str_none,
|
&value_str_none,
|
||||||
&send_value_date_time,
|
&value_date_time,
|
||||||
&send_value_date_time_none,
|
&value_date_time_none,
|
||||||
]);
|
]);
|
||||||
let list_ser = ron::ser::to_string(&list).unwrap();
|
let list_ser = ron::ser::to_string(&list).unwrap();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue