diff options
Diffstat (limited to 'src/classes/streaminginfo.rs')
-rw-r--r-- | src/classes/streaminginfo.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/classes/streaminginfo.rs b/src/classes/streaminginfo.rs index 1f8cadb..bb0b5e1 100644 --- a/src/classes/streaminginfo.rs +++ b/src/classes/streaminginfo.rs @@ -1,9 +1,7 @@ -use crate::object::Value; +use crate::object::{Value, parser::FromValue}; use anyhow::Result; use serde::Serialize; -use super::FromValue; - #[derive(Debug, Serialize)] pub struct StreamingInfo { pub offset: u64, @@ -12,11 +10,11 @@ pub struct StreamingInfo { } impl FromValue for StreamingInfo { fn from_value(v: Value) -> Result<Self> { - let fields = v.as_class("StreamingInfo").unwrap(); + let mut fields = v.as_class("StreamingInfo").unwrap(); Ok(StreamingInfo { - offset: fields["offset"].as_u64().unwrap(), - size: fields["size"].as_u32().unwrap(), - path: fields["path"].to_owned().as_string().unwrap(), + offset: fields.field("offset")?, + size: fields.field("size")?, + path: fields.field("path")?, }) } } |