aboutsummaryrefslogtreecommitdiff
path: root/src/classes/streaminginfo.rs
blob: 3ab271d40304aa9b7262cc8229bbddc750eedd57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use crate::object::Value;
use anyhow::Result;
use serde::Serialize;

use super::FromValue;

#[derive(Debug, Serialize)]
pub struct StreamingInfo {
    pub offset: u32,
    pub path: String,
    pub size: u32,
}
impl FromValue for StreamingInfo {
    fn from_value(v: Value) -> Result<Self> {
        let fields = v.as_class("StreamingInfo").unwrap();
        Ok(StreamingInfo {
            offset: fields["offset"].as_u32().unwrap(),
            size: fields["size"].as_u32().unwrap(),
            path: fields["path"].to_owned().as_string().unwrap(),
        })
    }
}