From 5555c8bbefb4f52f5002603eb91b6c95cbdd97e4 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Wed, 12 Mar 2025 22:39:58 +0100 Subject: more parsing helpers --- src/classes/streaminginfo.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/classes/streaminginfo.rs') 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 { - 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")?, }) } } -- cgit v1.2.3-70-g09d2