forked from mirrors/gstreamer-rs
gstreamer/datetime: Add TryFrom impls for converting between glib::DateTime and gst::DateTime
This commit is contained in:
parent
7dd0404927
commit
962da8a63d
1 changed files with 33 additions and 0 deletions
|
@ -7,6 +7,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
use std::cmp;
|
||||
use std::convert;
|
||||
use std::fmt;
|
||||
|
||||
use DateTime;
|
||||
|
@ -230,6 +231,38 @@ impl fmt::Display for DateTime {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> convert::TryFrom<&'a glib::DateTime> for DateTime {
|
||||
type Error = glib::BoolError;
|
||||
|
||||
fn try_from(v: &'a glib::DateTime) -> Result<DateTime, glib::BoolError> {
|
||||
DateTime::new_from_g_date_time(v)
|
||||
}
|
||||
}
|
||||
|
||||
impl convert::TryFrom<glib::DateTime> for DateTime {
|
||||
type Error = glib::BoolError;
|
||||
|
||||
fn try_from(v: glib::DateTime) -> Result<DateTime, glib::BoolError> {
|
||||
DateTime::new_from_g_date_time(&v)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> convert::TryFrom<&'a DateTime> for glib::DateTime {
|
||||
type Error = glib::BoolError;
|
||||
|
||||
fn try_from(v: &'a DateTime) -> Result<glib::DateTime, glib::BoolError> {
|
||||
v.to_g_date_time()
|
||||
}
|
||||
}
|
||||
|
||||
impl convert::TryFrom<DateTime> for glib::DateTime {
|
||||
type Error = glib::BoolError;
|
||||
|
||||
fn try_from(v: DateTime) -> Result<glib::DateTime, glib::BoolError> {
|
||||
v.to_g_date_time()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
Loading…
Reference in a new issue