pub struct JsonObjectImporter<'a, Store, Hasher = Blake3>{ /* private fields */ }Expand description
Deterministic JSON importer that derives entity ids from attribute/value pairs.
This importer expects either:
- a top-level JSON object, or
- a top-level array of JSON objects.
Use crate::import::json_tree::JsonTreeImporter when you need a lossless
representation of arbitrary JSON values (including primitive roots).
Implementations§
Source§impl<'a, Store, Hasher> JsonObjectImporter<'a, Store, Hasher>
impl<'a, Store, Hasher> JsonObjectImporter<'a, Store, Hasher>
Sourcepub fn new(store: &'a mut Store, id_salt: Option<[u8; 32]>) -> Self
pub fn new(store: &'a mut Store, id_salt: Option<[u8; 32]>) -> Self
Creates a new importer backed by store. Pass an optional 32-byte
salt to namespace the deterministic entity ids.
Sourcepub fn import_str(&mut self, input: &str) -> Result<Fragment, JsonImportError>
pub fn import_str(&mut self, input: &str) -> Result<Fragment, JsonImportError>
Imports a JSON string. Convenience wrapper around import_blob.
Sourcepub fn import_blob(
&mut self,
blob: Blob<LongString>,
) -> Result<Fragment, JsonImportError>
pub fn import_blob( &mut self, blob: Blob<LongString>, ) -> Result<Fragment, JsonImportError>
Imports a JSON document from a LongString blob, returning a
Fragment with the root entity ids as exports.
Auto Trait Implementations§
impl<'a, Store, Hasher> Freeze for JsonObjectImporter<'a, Store, Hasher>
impl<'a, Store, Hasher = Hasher> !RefUnwindSafe for JsonObjectImporter<'a, Store, Hasher>
impl<'a, Store, Hasher> Send for JsonObjectImporter<'a, Store, Hasher>where
Store: Send,
impl<'a, Store, Hasher> Sync for JsonObjectImporter<'a, Store, Hasher>
impl<'a, Store, Hasher> Unpin for JsonObjectImporter<'a, Store, Hasher>where
Hasher: Unpin,
impl<'a, Store, Hasher> UnsafeUnpin for JsonObjectImporter<'a, Store, Hasher>
impl<'a, Store, Hasher = Hasher> !UnwindSafe for JsonObjectImporter<'a, Store, Hasher>
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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