pub struct NewDataset {
pub original_id: String,
pub source_portal: String,
pub url: String,
pub title: String,
pub description: Option<String>,
pub embedding: Option<Vector>,
pub metadata: Value,
pub content_hash: String,
}Expand description
Data Transfer Object for inserting or updating datasets.
This structure is used when creating new datasets or updating existing ones.
Unlike Dataset, it doesn’t include database-generated fields like id or
timestamps. The embedding field uses pgvector’s Vector for database storage.
§Examples
use ceres_core::NewDataset;
use serde_json::json;
let title = "My Dataset";
let description = Some("Description here".to_string());
let content_hash = NewDataset::compute_content_hash(title, description.as_deref());
let dataset = NewDataset {
original_id: "dataset-123".to_string(),
source_portal: "https://dati.gov.it".to_string(),
url: "https://dati.gov.it/dataset/my-data".to_string(),
title: title.to_string(),
description,
embedding: None,
metadata: json!({"tags": ["open-data", "italy"]}),
content_hash,
};
assert_eq!(dataset.title, "My Dataset");
assert!(dataset.embedding.is_none());
assert_eq!(dataset.content_hash.len(), 64); // SHA-256 = 64 hex chars§Fields
original_id- Original identifier from the source portalsource_portal- Base URL of the originating CKAN portalurl- Public landing page URL for the datasettitle- Human-readable dataset titledescription- Optional detailed descriptionembedding- Optional vector of 768 floats (pgvector)metadata- Additional metadata as JSONcontent_hash- SHA-256 hash of title + description for delta detection
Fields§
§original_id: StringOriginal identifier from the source portal
source_portal: StringBase URL of the originating CKAN portal
url: StringPublic landing page URL for the dataset
title: StringHuman-readable dataset title
description: Option<String>Optional detailed description
embedding: Option<Vector>Optional vector of 768 floats (converted to pgvector on storage)
metadata: ValueAdditional metadata as JSON
content_hash: StringSHA-256 hash of title + description for delta detection
Implementations§
Source§impl NewDataset
impl NewDataset
Sourcepub fn compute_content_hash(title: &str, description: Option<&str>) -> String
pub fn compute_content_hash(title: &str, description: Option<&str>) -> String
Computes a SHA-256 hash of the content (title + description) for delta detection.
This hash is used to determine if the dataset content has changed since the last harvest, avoiding unnecessary embedding regeneration.
§Arguments
title- The dataset titledescription- Optional dataset description
§Returns
A 64-character lowercase hexadecimal string representing the SHA-256 hash.
Trait Implementations§
Source§impl Clone for NewDataset
impl Clone for NewDataset
Source§fn clone(&self) -> NewDataset
fn clone(&self) -> NewDataset
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NewDataset
impl Debug for NewDataset
Auto Trait Implementations§
impl Freeze for NewDataset
impl RefUnwindSafe for NewDataset
impl Send for NewDataset
impl Sync for NewDataset
impl Unpin for NewDataset
impl UnwindSafe for NewDataset
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more