gc_value 0.1.0

Generic value type, capturing the data model of common formats such as JSON, YAML and CBOR, based on Arc for cheap cloning.
Documentation
use std::sync::Arc;

use crate::{GcValue, Map};

impl From<&str> for GcValue {
    /// Convert to [`GcValue::Text`]
    fn from(value: &str) -> Self {
        Self::new_text(value)
    }
}

impl From<String> for GcValue {
    /// Convert to [`GcValue::Text`]
    fn from(value: String) -> Self {
        Self::new_text(value)
    }
}

impl From<Arc<str>> for GcValue {
    /// Convert to [`GcValue::Text`]
    fn from(value: Arc<str>) -> Self {
        Self::new_text(value)
    }
}

impl From<i8> for GcValue {
    /// Convert to [`GcValue::Int`]
    fn from(value: i8) -> Self {
        Self::new_int(value)
    }
}

impl From<i16> for GcValue {
    /// Convert to [`GcValue::Int`]
    fn from(value: i16) -> Self {
        Self::new_int(value)
    }
}

impl From<i32> for GcValue {
    /// Convert to [`GcValue::Int`]
    fn from(value: i32) -> Self {
        Self::new_int(value)
    }
}

impl From<i64> for GcValue {
    /// Convert to [`GcValue::Int`]
    fn from(value: i64) -> Self {
        Self::new_int(value)
    }
}

impl From<i128> for GcValue {
    /// Convert to [`GcValue::Int`]
    fn from(value: i128) -> Self {
        Self::new_int(value)
    }
}

impl From<isize> for GcValue {
    /// Convert to [`GcValue::Int`]
    fn from(value: isize) -> Self {
        Self::new_int(value as i128)
    }
}

impl From<u8> for GcValue {
    /// Convert to [`GcValue::Int`]
    fn from(value: u8) -> Self {
        Self::new_int(value)
    }
}

impl From<u16> for GcValue {
    /// Convert to [`GcValue::Int`]
    fn from(value: u16) -> Self {
        Self::new_int(value)
    }
}

impl From<u32> for GcValue {
    /// Convert to [`GcValue::Int`]
    fn from(value: u32) -> Self {
        Self::new_int(value)
    }
}

impl From<u64> for GcValue {
    /// Convert to [`GcValue::Int`]
    fn from(value: u64) -> Self {
        Self::new_int(value)
    }
}

impl From<usize> for GcValue {
    /// Convert to [`GcValue::Int`]
    fn from(value: usize) -> Self {
        Self::new_int(value as i128)
    }
}

impl From<f32> for GcValue {
    /// Convert to [`GcValue::Float`]
    fn from(value: f32) -> Self {
        Self::new_float(value)
    }
}

impl From<f64> for GcValue {
    /// Convert to [`GcValue::Float`]
    fn from(value: f64) -> Self {
        Self::new_float(value)
    }
}

impl From<bool> for GcValue {
    /// Convert to [`GcValue::Boolean`]
    fn from(value: bool) -> Self {
        Self::new_boolean(value)
    }
}

impl From<Arc<[GcValue]>> for GcValue {
    /// Convert to [`GcValue::Array`]
    fn from(value: Arc<[GcValue]>) -> Self {
        Self::new_array(value)
    }
}

impl From<Vec<GcValue>> for GcValue {
    /// Convert to [`GcValue::Array`]
    fn from(value: Vec<GcValue>) -> Self {
        Self::new_array(value)
    }
}

impl From<&[GcValue]> for GcValue {
    /// Convert to [`GcValue::Array`]
    fn from(value: &[GcValue]) -> Self {
        Self::new_array(value)
    }
}

impl From<Arc<Map>> for GcValue {
    /// Convert to [`GcValue::Map`]
    fn from(value: Arc<Map>) -> Self {
        Self::new_map(value)
    }
}

impl From<Arc<(GcValue, GcValue)>> for GcValue {
    /// Convert to [`GcValue::Tag`]
    fn from(value: Arc<(GcValue, GcValue)>) -> Self {
        Self::new_tag(value)
    }
}

impl From<Arc<[u8]>> for GcValue {
    /// Convert to [`GcValue::Bytes`]
    fn from(value: Arc<[u8]>) -> Self {
        Self::new_bytes(value)
    }
}

impl<const N: usize> From<&[u8; N]> for GcValue {
    /// Convert to [`GcValue::Bytes`]
    fn from(value: &[u8; N]) -> Self {
        Self::new_bytes(&value[..])
    }
}

impl From<()> for GcValue {
    /// Convert to [`GcValue::Null`]
    fn from(_: ()) -> Self {
        Self::new_null()
    }
}

impl FromIterator<GcValue> for GcValue {
    /// Convert to [`GcValue::Array`]
    fn from_iter<T: IntoIterator<Item = GcValue>>(iter: T) -> Self {
        Self::collect_array(iter)
    }
}

impl FromIterator<(GcValue, GcValue)> for GcValue {
    /// Convert to [`GcValue::Map`]
    fn from_iter<T: IntoIterator<Item = (GcValue, GcValue)>>(iter: T) -> Self {
        Self::collect_map(iter)
    }
}

impl FromIterator<u8> for GcValue {
    /// Convert to [`GcValue::Bytes`]
    fn from_iter<T: IntoIterator<Item = u8>>(iter: T) -> Self {
        Self::collect_bytes(iter)
    }
}