pub struct PropertyMapBuilder { /* private fields */ }Expand description
Builder for creating graph element property maps
PropertyMapBuilder provides a fluent API for constructing ElementPropertyMap instances
used when inserting or updating nodes and relationships in the graph.
§Supported Property Types
- String: Text values
- Integer: 64-bit signed integers
- Float: 64-bit floating point numbers
- Boolean: true/false values
- Null: Explicit null values
§Thread Safety
PropertyMapBuilder is not thread-safe. Create a new builder for each thread.
§Examples
§Basic Usage
use drasi_source_application::PropertyMapBuilder;
let properties = PropertyMapBuilder::new()
.with_string("name", "Alice")
.with_integer("age", 30)
.with_bool("active", true)
.with_float("score", 95.5)
.build();§With Application Source
use drasi_source_application::{ApplicationSource, ApplicationSourceConfig, PropertyMapBuilder};
use std::collections::HashMap;
let config = ApplicationSourceConfig { properties: HashMap::new() };
let (source, handle) = ApplicationSource::new("events", config)?;
// Create a user node with multiple properties
let properties = PropertyMapBuilder::new()
.with_string("username", "alice")
.with_string("email", "alice@example.com")
.with_integer("age", 30)
.with_bool("verified", true)
.with_float("rating", 4.8)
.build();
handle.send_node_insert("user-1", vec!["User"], properties).await?;§Null Values
use drasi_source_application::PropertyMapBuilder;
let properties = PropertyMapBuilder::new()
.with_string("name", "Bob")
.with_null("middle_name") // Explicit null
.build();Implementations§
Source§impl PropertyMapBuilder
impl PropertyMapBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new empty property map builder
§Examples
use drasi_source_application::PropertyMapBuilder;
let builder = PropertyMapBuilder::new();
let properties = builder.build();Sourcepub fn with_integer(self, key: impl AsRef<str>, value: i64) -> Self
pub fn with_integer(self, key: impl AsRef<str>, value: i64) -> Self
Sourcepub fn with_float(self, key: impl AsRef<str>, value: f64) -> Self
pub fn with_float(self, key: impl AsRef<str>, value: f64) -> Self
Sourcepub fn with_null(self, key: impl AsRef<str>) -> Self
pub fn with_null(self, key: impl AsRef<str>) -> Self
Add an explicit null property
Use this to explicitly set a property to null, which is different from not having the property at all.
§Arguments
key- Property name
§Examples
use drasi_source_application::PropertyMapBuilder;
let properties = PropertyMapBuilder::new()
.with_string("first_name", "Alice")
.with_null("middle_name") // Explicitly null
.with_string("last_name", "Smith")
.build();Sourcepub fn build(self) -> ElementPropertyMap
pub fn build(self) -> ElementPropertyMap
Build the final property map
Consumes the builder and returns the constructed ElementPropertyMap.
§Examples
use drasi_source_application::PropertyMapBuilder;
let properties = PropertyMapBuilder::new()
.with_string("name", "Alice")
.with_integer("age", 30)
.build();
// properties can now be used with send_node_insert, send_node_update, etc.Trait Implementations§
Auto Trait Implementations§
impl Freeze for PropertyMapBuilder
impl RefUnwindSafe for PropertyMapBuilder
impl Send for PropertyMapBuilder
impl Sync for PropertyMapBuilder
impl Unpin for PropertyMapBuilder
impl UnsafeUnpin for PropertyMapBuilder
impl UnwindSafe for PropertyMapBuilder
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