Skip to main content

PropertyMapBuilder

Struct PropertyMapBuilder 

Source
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

Source

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();
Source

pub fn with_string(self, key: impl AsRef<str>, value: impl Into<String>) -> Self

Add a string property

§Arguments
  • key - Property name
  • value - String value (converted to Arc<str> internally)
§Examples
use drasi_source_application::PropertyMapBuilder;

let properties = PropertyMapBuilder::new()
    .with_string("name", "Alice")
    .with_string("email", "alice@example.com")
    .build();
Source

pub fn with_integer(self, key: impl AsRef<str>, value: i64) -> Self

Add an integer property (64-bit signed)

§Arguments
  • key - Property name
  • value - Integer value (i64)
§Examples
use drasi_source_application::PropertyMapBuilder;

let properties = PropertyMapBuilder::new()
    .with_integer("age", 30)
    .with_integer("count", 1000)
    .build();
Source

pub fn with_float(self, key: impl AsRef<str>, value: f64) -> Self

Add a floating-point property (64-bit)

§Arguments
  • key - Property name
  • value - Float value (f64)
§Examples
use drasi_source_application::PropertyMapBuilder;

let properties = PropertyMapBuilder::new()
    .with_float("rating", 4.5)
    .with_float("price", 29.99)
    .build();
Source

pub fn with_bool(self, key: impl AsRef<str>, value: bool) -> Self

Add a boolean property

§Arguments
  • key - Property name
  • value - Boolean value
§Examples
use drasi_source_application::PropertyMapBuilder;

let properties = PropertyMapBuilder::new()
    .with_bool("active", true)
    .with_bool("verified", false)
    .build();
Source

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();
Source

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§

Source§

impl Default for PropertyMapBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more