Sha256: 39e47f3f8453e06dbbc13910b50e9e5b8adf2dfa55e26da5e7ff0520340dbbeb

Contents?: true

Size: 1017 Bytes

Versions: 31

Compression:

Stored size: 1017 Bytes

Contents

use serde::ser::{Serialize, SerializeSeq, Serializer};

use crate::Timestamp;

pub struct SerializableSingleValueColumn<T: Serialize>(pub T, pub usize);

impl<T: Serialize> Serialize for SerializableSingleValueColumn<T> {
    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        let mut seq = serializer.serialize_seq(Some(self.1))?;
        for _ in 0..self.1 {
            seq.serialize_element(&self.0)?;
        }
        seq.end()
    }
}

pub struct SerializableOptionalTimestampColumn<'a>(pub &'a [Option<Timestamp>]);

impl<'a> Serialize for SerializableOptionalTimestampColumn<'a> {
    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        let mut seq = serializer.serialize_seq(Some(self.0.len()))?;
        for timestamp in self.0 {
            match timestamp {
                Some(timestamp) => seq.serialize_element(&timestamp)?,
                None => seq.serialize_element(&0.0)?,
            }
        }
        seq.end()
    }
}

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/fxprof-processed-profile-0.6.0/src/serialization_helpers.rs
wasmtime-28.0.0 ./ext/cargo-vendor/fxprof-processed-profile-0.6.0/src/serialization_helpers.rs
wasmtime-27.0.0 ./ext/cargo-vendor/fxprof-processed-profile-0.6.0/src/serialization_helpers.rs
wasmtime-26.0.0 ./ext/cargo-vendor/fxprof-processed-profile-0.6.0/src/serialization_helpers.rs
wasmtime-25.0.2 ./ext/cargo-vendor/fxprof-processed-profile-0.6.0/src/serialization_helpers.rs
wasmtime-25.0.1 ./ext/cargo-vendor/fxprof-processed-profile-0.6.0/src/serialization_helpers.rs
wasmtime-25.0.0 ./ext/cargo-vendor/fxprof-processed-profile-0.6.0/src/serialization_helpers.rs
wasmtime-24.0.0 ./ext/cargo-vendor/fxprof-processed-profile-0.6.0/src/serialization_helpers.rs
wasmtime-23.0.2 ./ext/cargo-vendor/fxprof-processed-profile-0.6.0/src/serialization_helpers.rs
wasmtime-22.0.0 ./ext/cargo-vendor/fxprof-processed-profile-0.6.0/src/serialization_helpers.rs
wasmtime-21.0.1 ./ext/cargo-vendor/fxprof-processed-profile-0.6.0/src/serialization_helpers.rs
wasmtime-20.0.2 ./ext/cargo-vendor/fxprof-processed-profile-0.6.0/src/serialization_helpers.rs
wasmtime-20.0.0 ./ext/cargo-vendor/fxprof-processed-profile-0.6.0/src/serialization_helpers.rs
wasmtime-18.0.3 ./ext/cargo-vendor/fxprof-processed-profile-0.6.0/src/serialization_helpers.rs
wasmtime-17.0.1 ./ext/cargo-vendor/fxprof-processed-profile-0.6.0/src/serialization_helpers.rs
wasmtime-17.0.0 ./ext/cargo-vendor/fxprof-processed-profile-0.6.0/src/serialization_helpers.rs
wasmtime-16.0.0 ./ext/cargo-vendor/fxprof-processed-profile-0.6.0/src/serialization_helpers.rs
wasmtime-15.0.1 ./ext/cargo-vendor/fxprof-processed-profile-0.6.0/src/serialization_helpers.rs
wasmtime-15.0.0 ./ext/cargo-vendor/fxprof-processed-profile-0.6.0/src/serialization_helpers.rs
wasmtime-14.0.4 ./ext/cargo-vendor/fxprof-processed-profile-0.6.0/src/serialization_helpers.rs