| 155 | |
| 156 | impl Distribution<PropertyValueWithMetadata> for ValueDistribution<'_> { |
| 157 | fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> PropertyValueWithMetadata { |
| 158 | let value = match &self.value { |
| 159 | InnerValueDistribution::Null => PropertyValue::Null, |
| 160 | InnerValueDistribution::Boolean(boolean) => PropertyValue::Bool(boolean.sample(rng)), |
| 161 | InnerValueDistribution::Number(number) => PropertyValue::Number(number.sample(rng)), |
| 162 | InnerValueDistribution::String(string) => PropertyValue::String(string.sample(rng)), |
| 163 | }; |
| 164 | |
| 165 | PropertyValueWithMetadata { |
| 166 | value, |
| 167 | metadata: ValueMetadata { |
| 168 | data_type_id: Some(self.data_type_url.clone().into_owned()), |
| 169 | ..ValueMetadata::default() |
| 170 | }, |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | pub trait ValueDistributionRegistry { |