### Install FalkorDB Rust Client Source: https://docs.rs/falkordb/0.1.11/falkordb/index Instructions for adding the FalkorDB Rust client to your project's Cargo.toml file. ```toml falkordb = { version = "0.1.10" } ``` -------------------------------- ### Connect and Query FalkorDB Source: https://docs.rs/falkordb/0.1.11/index Demonstrates how to establish a connection to FalkorDB, select a graph, execute a query to create nodes, and iterate over the results. This example uses the synchronous API. ```rust use falkordb::{FalkorClientBuilder, FalkorConnectionInfo}; // Connect to FalkorDB let connection_info: FalkorConnectionInfo = "falkor://127.0.0.1:6379".try_into() .expect("Invalid connection info"); let client = FalkorClientBuilder::new() .with_connection_info(connection_info) .build() .expect("Failed to build client"); // Select the social graph let mut graph = client.select_graph("social"); // Create 100 nodes and return a handful let mut nodes = graph.query("UNWIND range(0, 100) AS i CREATE (n { v:1 }) RETURN n LIMIT 10") .with_timeout(5000) .execute() .expect("Failed executing query"); // Can also be collected, like any other iterator while let Some(node) = nodes.data.next() { println ! ("{:?}", node); } ``` -------------------------------- ### Connect and Query FalkorDB Source: https://docs.rs/falkordb/0.1.11/falkordb Demonstrates how to establish a connection to FalkorDB, select a graph, execute a query to create nodes, and iterate over the results. This example uses the synchronous API. ```rust use falkordb::{FalkorClientBuilder, FalkorConnectionInfo}; // Connect to FalkorDB let connection_info: FalkorConnectionInfo = "falkor://127.0.0.1:6379".try_into() .expect("Invalid connection info"); let client = FalkorClientBuilder::new() .with_connection_info(connection_info) .build() .expect("Failed to build client"); // Select the social graph let mut graph = client.select_graph("social"); // Create 100 nodes and return a handful let mut nodes = graph.query("UNWIND range(0, 100) AS i CREATE (n { v:1 }) RETURN n LIMIT 10") .with_timeout(5000) .execute() .expect("Failed executing query"); // Can also be collected, like any other iterator while let Some(node) = nodes.data.next() { println ! ("{:?}", node); } ``` -------------------------------- ### Set Configuration Value Source: https://docs.rs/falkordb/0.1.11/src/falkordb/client/blocking.rs Provides an example of setting a specific configuration parameter for the FalkorDB client. This snippet initializes the client and prepares for a configuration update. ```rust let client = create_test_client(); // ... subsequent code to set config ``` -------------------------------- ### FalkorAsyncClient API Documentation Source: https://docs.rs/falkordb/0.1.11/falkordb/struct.FalkorAsyncClient Provides comprehensive API documentation for the FalkorAsyncClient, including method signatures, parameters, return values, and usage examples for interacting with FalkorDB asynchronously. ```APIDOC FalkorAsyncClient: Thread Safety: Fully thread safe, can be cloned and passed between threads without constraints. API uses only immutable references. Methods: connection_pool_size(&self) -> u8 Description: Get the max number of connections in the client’s connection pool. Returns: The maximum number of connections (u8). list_graphs(&self) -> FalkorResult> Description: Return a list of graphs currently residing in the database. Returns: A Vec of Strings, containing the names of available graphs. Example: let graphs = client.list_graphs().await.unwrap(); config_get(&self, config_key: &str) -> FalkorResult> Description: Return the current value of a configuration option in the database. Arguments: config_key: A String representation of a configuration’s key. Can also be “*” to return ALL configuration options. Returns: A HashMap comprised of String keys, and ConfigValue values. Example: let mut config = HashMap::new(); config.insert("some_key".to_string(), ConfigValue::Integer(10)); let result = client.config_get("*").await.unwrap(); config_set>(&self, config_key: &str, value: C) -> FalkorResult Description: Set the value of a configuration option in the database. Arguments: config_key: A String representation of a configuration’s key. value: The value to set for the configuration option. Must implement Into. Returns: The updated value of the configuration option. Example: let result = client.config_set("some_key", 10).await.unwrap(); ``` -------------------------------- ### Execute Query (Rust) Source: https://docs.rs/falkordb/0.1.11/src/falkordb/graph/blocking.rs Provides an example of executing a simple Cypher query to generate a range of numbers. This demonstrates the basic query execution capability of the FalkorDB Rust client. ```rust let mut graph = open_empty_test_graph("test_slowlog"); graph.inner.query("UNWIND range(0, 500) AS x RETURN x").execute().expect("Could not generate the fast query"); ``` -------------------------------- ### FalkorDB Configuration API Source: https://docs.rs/falkordb/0.1.11/src/falkordb/client/blocking.rs Provides methods for getting and setting configuration values in FalkorDB. Supports retrieving all configurations using '*' as the key. Handles string and i64 values for setting configuration. ```APIDOC GRAPH.LIST - Lists all graphs in the database. - Returns: A vector of strings representing graph names. GRAPH.CONFIG GET config_key - Retrieves the value of a specific configuration key or all configurations if '*' is used. - Arguments: - config_key: The key of the configuration option to retrieve (String). Can be "*". - Returns: A HashMap containing the configuration key-value pairs. - Example: ```rust let config_map = client.config_get("*").unwrap(); ``` GRAPH.CONFIG SET config_key value - Sets the value of a specific configuration key. - Arguments: - config_key: The key of the configuration option to set (String). - value: The new value to set. Can be a string type or i64. - Returns: The Redis Value indicating success or failure. - Example: ```rust client.config_set("timeout", 5000).unwrap(); ``` ``` -------------------------------- ### List Constraints (Rust) Source: https://docs.rs/falkordb/0.1.11/src/falkordb/graph/blocking.rs Shows how to list all existing constraints on a FalkorDB graph. This example first creates a unique constraint and then verifies that it appears in the list of constraints. ```rust let mut graph = open_empty_test_graph("test_list_constraints"); graph.inner.create_unique_constraint(EntityType::Node, "actor".to_string(), &["first_name", "last_name"]).expect("Could not create constraint"); let res = graph.inner.list_constraints().expect("Could not list constraints"); assert_eq!(res.data.len(), 1); ``` -------------------------------- ### Get All Configuration Values Source: https://docs.rs/falkordb/0.1.11/src/falkordb/client/blocking.rs Illustrates fetching all available configuration settings from the FalkorDB client using a wildcard. It includes an assertion to verify a specific configuration value, like 'THREAD_COUNT', against the system's available parallelism. ```rust let configuration = client.config_get("*").expect("Could not get configuration"); assert_eq!(configuration.get("THREAD_COUNT").cloned().unwrap(), ConfigValue::Int64(thread::available_parallelism().unwrap().get() as i64)) ``` -------------------------------- ### FalkorDB Query Explanation Source: https://docs.rs/falkordb/0.1.11/src/falkordb/graph/blocking.rs Shows how to use the `explain` functionality of the FalkorDB Rust client to get the execution plan for a Cypher query. It includes checking the number of operations and the presence of specific operations like 'Aggregate'. ```rust let mut graph = create_test_client().select_graph("imdb"); // Get the execution plan for a query let execution_plan = graph.explain("MATCH (a:actor) WITH a MATCH (b:actor) WHERE a.age = b.age AND a <> b RETURN a, collect(b) LIMIT 100").execute().expect("Could not create execution plan"); // Assertions on the execution plan assert_eq!(execution_plan.plan().len(), 7); assert!(execution_plan.operations().get("Aggregate").is_some()); assert_eq!(execution_plan.operations()["Aggregate"].len(), 1); // Get the string representation of the plan let plan_string = execution_plan.string_representation(); ``` -------------------------------- ### FalkorClientBuilder: Get Client Provider Source: https://docs.rs/falkordb/0.1.11/src/falkordb/client/builder.rs Internal helper function to get a `FalkorClientProvider` based on provided connection information. It handles conversion and error mapping for Redis connections. ```rust fn get_client>( connection_info: T ) -> FalkorResult { let connection_info = connection_info .try_into() .map_err(|err| FalkorDBError::InvalidConnectionInfo(err.to_string()))?; Ok(match connection_info { FalkorConnectionInfo::Redis(connection_info) => FalkorClientProvider::Redis { client: redis::Client::open(connection_info.clone()) .map_err(|err| FalkorDBError::RedisError(err.to_string()))?, sentinel: None, }, }) } ``` -------------------------------- ### Get Sentinel Client (Sync) Source: https://docs.rs/falkordb/0.1.11/src/falkordb/client/mod.rs Retrieves a synchronous Sentinel client for FalkorDB. This function first checks if the connection is to a Redis Sentinel. If not, it returns None. It then executes the 'SENTINEL MASTERS' command to get master information and uses this to establish the Sentinel client. ```rust pub(crate) fn get_sentinel_client( &mut self, connection_info: &redis::ConnectionInfo, ) -> FalkorResult> { let mut conn = self.get_connection()?; if !conn.check_is_redis_sentinel()? { return Ok(None); } conn.execute_command(None, "SENTINEL", Some("MASTERS"), None) .and_then(redis_value_as_vec) .and_then(|sentinel_masters| { self.get_sentinel_client_common(connection_info, sentinel_masters) }) } ``` -------------------------------- ### Get Graph Name Source: https://docs.rs/falkordb/0.1.11/src/falkordb/graph/asynchronous.rs Retrieves the name of the graph for which the AsyncGraph API performs operations. ```rust /// Returns the name of the graph for which this API performs operations. /// ``` -------------------------------- ### Get String Representation Source: https://docs.rs/falkordb/0.1.11/src/falkordb/response/execution_plan.rs Retrieves the string representation of an execution plan node. This method is part of the `ExecutionPlan` struct. ```rust pub fn string_representation(&self) -> &str { self.string_representation.as_str() } ``` -------------------------------- ### FalkorDB Connection Info Module Source: https://docs.rs/falkordb/0.1.11/src/falkordb/client/mod.rs Documentation for the connection information module, which likely handles details related to establishing and maintaining connections. ```rust connection_info/mod.rs ``` -------------------------------- ### Get Connection Pool Size Source: https://docs.rs/falkordb/0.1.11/src/falkordb/client/blocking.rs Retrieves the maximum number of connections configured for the FalkorDB client's connection pool. ```rust pub fn connection_pool_size(&self) -> u8 { self.inner.connection_pool_size } ``` -------------------------------- ### FalkorDB Rust Client Source and Links Source: https://docs.rs/falkordb/0.1.11/src/falkordb/client/builder.rs Provides links to the source code, documentation, and related resources for the falkorDB Rust client version 0.1.11. This includes direct links to the docs.rs page, the source code repository on GitHub, and the crate's page on crates.io. ```Rust Source Code: https://github.com/FalkorDB/falkordb-rs Docs.rs: https://docs.rs/falkordb/0.1.11 Crates.io: https://crates.io/crates/falkordb ``` -------------------------------- ### FalkorDB Connection Info Module Source: https://docs.rs/falkordb/0.1.11/src/falkordb/value/config.rs Documentation for the connection information module, which likely handles details related to establishing and maintaining connections. ```rust connection_info/mod.rs ``` -------------------------------- ### Get Internal Execution Time Source: https://docs.rs/falkordb/0.1.11/src/falkordb/response/mod.rs Retrieves the internal execution time of the query in seconds. Returns an Option representing the time. ```rust pub fn get_internal_execution_time(&self) -> Option { self.get_statistics(StatisticType::InternalExecutionTime) } ``` -------------------------------- ### FalkorDB Connection Info Module Source: https://docs.rs/falkordb/0.1.11/src/falkordb/connection/asynchronous.rs Documentation for the connection information module, which likely handles details related to establishing and maintaining connections. ```rust connection_info/mod.rs ``` -------------------------------- ### Get Relationships Deleted Source: https://docs.rs/falkordb/0.1.11/src/falkordb/response/mod.rs Retrieves the number of relationships deleted during the query execution. This method returns an Option representing the count. ```rust pub fn get_relationship_deleted(&self) -> Option { self.get_statistics(StatisticType::RelationshipsDeleted) } ``` -------------------------------- ### FalkorDB Connection Info Module Source: https://docs.rs/falkordb/0.1.11/src/falkordb/lib.rs Documentation for the connection information module, which likely handles details related to establishing and maintaining connections. ```rust connection_info/mod.rs ``` -------------------------------- ### Create Test Client and Select Graph Source: https://docs.rs/falkordb/0.1.11/src/falkordb/graph_schema/mod.rs This Rust code snippet shows how to set up a test environment for FalkorDB. It utilizes utility functions to create a test client and then select a specific graph named 'imdb'. This is a common pattern for integration testing, allowing interaction with a mock or test instance of the database. ```rust let client = create_test_client(); let mut graph = client.select_graph("imdb"); ``` -------------------------------- ### Get Cached Execution Status Source: https://docs.rs/falkordb/0.1.11/src/falkordb/response/mod.rs Checks if the query was executed from cache. Returns an Option, where true indicates cached execution. ```rust pub fn get_cached_execution(&self) -> Option { self.get_statistics(StatisticType::CachedExecution) .map(|res: i64| res != 0) } ``` -------------------------------- ### Get Relationships Created Source: https://docs.rs/falkordb/0.1.11/src/falkordb/response/mod.rs Retrieves the number of relationships created during the query execution. This method returns an Option representing the count. ```rust pub fn get_relationship_created(&self) -> Option { self.get_statistics(StatisticType::RelationshipsCreated) } ``` -------------------------------- ### FalkorDB Connection Info Module Source: https://docs.rs/falkordb/0.1.11/src/falkordb/value/mod.rs Documentation for the connection information module, which likely handles details related to establishing and maintaining connections. ```rust connection_info/mod.rs ``` -------------------------------- ### Get Indices Deleted Source: https://docs.rs/falkordb/0.1.11/src/falkordb/response/mod.rs Retrieves the number of indices deleted during the query execution. This method returns an Option representing the count. ```rust pub fn get_indices_deleted(&self) -> Option { self.get_statistics(StatisticType::IndicesDeleted) } ``` -------------------------------- ### FalkorDB Rust Client Source and Links Source: https://docs.rs/falkordb/0.1.11/src/falkordb/client/asynchronous.rs Provides links to the source code, documentation, and related resources for the falkordb Rust client. This includes the official docs.rs page, the source code repository on GitHub, and the crate's page on crates.io. ```rust Source Code: https://github.com/FalkorDB/falkordb-rs Docs.rs: https://docs.rs/falkordb/0.1.11/ Crates.io: https://crates.io/crates/falkordb ``` -------------------------------- ### Get Indices Created Source: https://docs.rs/falkordb/0.1.11/src/falkordb/response/mod.rs Retrieves the number of indices created during the query execution. This method returns an Option representing the count. ```rust pub fn get_indices_created(&self) -> Option { self.get_statistics(StatisticType::IndicesCreated) } ``` -------------------------------- ### FalkorDB Connection Info Module Source: https://docs.rs/falkordb/0.1.11/src/falkordb/graph/mod.rs Documentation for the connection information module, which likely handles details related to establishing and maintaining connections. ```rust connection_info/mod.rs ``` -------------------------------- ### FalkorDB Connection Info Module Source: https://docs.rs/falkordb/0.1.11/src/falkordb/graph/blocking.rs Documentation for the connection information module, which likely handles details related to establishing and maintaining connections. ```rust connection_info/mod.rs ``` -------------------------------- ### FalkorDB Connection Info Module Source: https://docs.rs/falkordb/0.1.11/src/falkordb/response/slowlog_entry.rs Documentation for the connection information module, which likely handles details related to establishing and maintaining connections. ```rust connection_info/mod.rs ``` -------------------------------- ### Get Redis Info - FalkorDB Rust Source: https://docs.rs/falkordb/0.1.11/src/falkordb/client/asynchronous.rs Retrieves information about the Redis instance. This function is used to fetch general information related to the Redis connection. ```rust #[cfg_attr( feature = "tracing", tracing::instrument(name = "Client Get Redis Info", skip_all, level = "info") )] // Function definition for getting redis info would go here. ``` -------------------------------- ### FalkorDB Connection Info Module Source: https://docs.rs/falkordb/0.1.11/src/falkordb/value/path.rs Documentation for the connection information module, which likely handles details related to establishing and maintaining connections. ```rust connection_info/mod.rs ``` -------------------------------- ### Get Synchronous Connection Source: https://docs.rs/falkordb/0.1.11/src/falkordb/client/blocking.rs Retrieves a synchronous connection from the FalkorDB client's connection pool. This method is instrumented for tracing and handles potential connection errors. ```rust impl ProvidesSyncConnections for FalkorSyncClientInner { #[cfg_attr( feature = "tracing", tracing::instrument( name = "Get New Sync Connection From Client", skip_all, level = "info" ) )] fn get_connection(&self) -> FalkorResult { self._inner.lock().get_connection() } } ``` -------------------------------- ### FalkorDB Rust Client Source and Links Source: https://docs.rs/falkordb/0.1.11/src/falkordb/connection/mod.rs Provides links to the FalkorDB Rust client's source code repository, documentation on docs.rs, and its listing on crates.io. It also includes information about the license and project website. ```rust Project: FalkorDB Rust Client Version: 0.1.11 License: MIT Source: https://github.com/FalkorDB/falkordb-rs Docs: https://docs.rs/falkordb/0.1.11/ Crates.io: https://crates.io/crates/falkordb Website: https://www.falkordb.com/ ``` -------------------------------- ### Get Redis Info (Rust) Source: https://docs.rs/falkordb/0.1.11/src/falkordb/connection/asynchronous.rs Retrieves information about the Redis server, optionally filtered by a specific section. This function is instrumented for tracing if the 'tracing' feature is enabled. ```rust pub(crate) async fn get_redis_info( &mut self, section: Option<&str>, ) -> FalkorResult> { self.execute_command(None, "INFO", section, None) .await .and_then(parse_redis_info) } ``` -------------------------------- ### FalkorDB Connection Info Module Source: https://docs.rs/falkordb/0.1.11/src/falkordb/error/mod.rs Documentation for the connection information module, which likely handles details related to establishing and maintaining connections. ```rust connection_info/mod.rs ``` -------------------------------- ### FalkorDB: Fallback Provider Example Source: https://docs.rs/falkordb/0.1.11/src/falkordb/connection_info/mod.rs Demonstrates setting a fallback Redis provider for FalkorDB connection. It shows how to create a connection info with a fallback and assert its address. ```rust let mut redis = FalkorConnectionInfo::fallback_provider("redis://127.0.0.1:6379".to_string()).unwrap(); assert_eq!(redis.addr.to_string(), "127.0.0.1:6379".to_string()); ``` -------------------------------- ### FalkorDB Connection Info Module Source: https://docs.rs/falkordb/0.1.11/src/falkordb/response/mod.rs Documentation for the connection information module, which likely handles details related to establishing and maintaining connections. ```rust connection_info/mod.rs ``` -------------------------------- ### FalkorDB Connection Info Module Source: https://docs.rs/falkordb/0.1.11/src/falkordb/connection_info/mod.rs Documentation for the connection information module, which likely handles details related to establishing and maintaining connections. ```rust connection_info/mod.rs ``` -------------------------------- ### FalkorDB Rust Client Source and Links Source: https://docs.rs/falkordb/0.1.11/src/falkordb/client/blocking.rs Provides links to the FalkorDB Rust client's source code repository, documentation on docs.rs, and its presence on crates.io. Also includes links to the FalkorDB website and license information. ```Rust Source: https://github.com/FalkorDB/falkordb-rs Docs: https://docs.rs/falkordb/0.1.11 Crates.io: https://crates.io/crates/falkordb License: MIT ``` -------------------------------- ### FalkorDB Connection Info Module Source: https://docs.rs/falkordb/0.1.11/src/falkordb/client/blocking.rs Documentation for the connection information module, which likely handles details related to establishing and maintaining connections. ```rust connection_info/mod.rs ``` -------------------------------- ### FalkorDB ExecutionPlan Methods Source: https://docs.rs/falkordb/0.1.11/src/falkordb/response/execution_plan.rs Provides methods to interact with the `ExecutionPlan`. These include retrieving the plan as a slice of strings, accessing the map of operations, and getting a pointer to the operation tree. ```rust impl ExecutionPlan { /// Returns the plan as a slice of human-readable strings pub fn plan(&self) -> &[String] { self.plan.as_slice() } /// Returns a slice of strings representing each step in the execution plan, which can be iterated. pub fn operations(&self) -> &HashMap>> { &self.operations } /// Returns a shared pointer to the operation tree, allowing easy immutable traversal pub fn operation_tree(&self) -> &Rc { &self.operation_tree } /// Returns a string representation of the entire execution plan } ``` -------------------------------- ### FalkorDB Connection Info Module Source: https://docs.rs/falkordb/0.1.11/src/falkordb/response/constraint.rs Documentation for the connection information module, which likely handles details related to establishing and maintaining connections. ```rust connection_info/mod.rs ``` -------------------------------- ### FalkorDB Graph Schema Get ID Map by Type Source: https://docs.rs/falkordb/0.1.11/src/falkordb/graph_schema/mod.rs Retrieves the appropriate `IdMap` based on the provided `SchemaType` (Labels, Properties, or Relationships). This is an internal helper method. ```rust #[inline] fn get_id_map_by_schema_type( &self, schema_type: SchemaType, ) -> &IdMap { match schema_type { SchemaType::Labels => &self.labels, // Other schema types would be handled here } } ``` -------------------------------- ### Synchronous FalkorDB Client Creation Source: https://docs.rs/falkordb/0.1.11/src/falkordb/client/builder.rs Demonstrates the creation of a synchronous FalkorDB client using the builder pattern. It involves setting connection information and building the client, with assertions to check for successful creation. ```rust let connection_info = "falkor://127.0.0.1:6379".try_into(); assert!(connection_info.is_ok()); assert!(FalkorClientBuilder::new() .with_connection_info(connection_info.unwrap()) .build() .is_ok()); ``` -------------------------------- ### Get Redis Info Source: https://docs.rs/falkordb/0.1.11/src/falkordb/connection/blocking.rs Retrieves information about the Redis server, optionally filtered by a specific section. This function is useful for inspecting the Redis server's configuration and status. ```rust pub(crate) fn get_redis_info(&mut self, section: Option<&str>) -> FalkorResult> { self.execute_command(None, "INFO", section, None) .and_then(parse_redis_info) } ``` -------------------------------- ### FalkorDB Connection Info Module Source: https://docs.rs/falkordb/0.1.11/src/falkordb/parser/mod.rs Documentation for the connection information module, which likely handles details related to establishing and maintaining connections. ```rust connection_info/mod.rs ``` -------------------------------- ### Test Get Thread Count Configuration Source: https://docs.rs/falkordb/0.1.11/src/falkordb/client/asynchronous.rs Tests the functionality to retrieve the 'THREAD_COUNT' configuration from the FalkorDB client asynchronously. It compares the retrieved value with the available parallelism of the system. ```rust #[tokio::test(flavor = "multi_thread")] async fn test_get_config() { let client = create_async_test_client().await; let configuration = client .config_get("*") .await .expect("Could not get configuration"); assert_eq!( configuration.get("THREAD_COUNT").cloned().unwrap(), ConfigValue::Int64(thread::available_parallelism().unwrap().get() as i64) ); } ``` -------------------------------- ### Get Synchronous Connection Source: https://docs.rs/falkordb/0.1.11/src/falkordb/client/mod.rs Retrieves a synchronous Redis connection from the FalkorClientProvider. It handles both direct Redis clients and Sentinel-managed clients, abstracting the connection logic. Errors during connection are mapped to FalkorDBError. ```rust impl FalkorClientProvider { pub(crate) fn get_connection(&mut self) -> FalkorResult { Ok(match self { FalkorClientProvider::Redis { sentinel: Some(sentinel), .. } => FalkorSyncConnection::Redis( sentinel .get_connection() .map_err(|err| FalkorDBError::RedisError(err.to_string()))?, ), FalkorClientProvider::Redis { client, .. } => FalkorSyncConnection::Redis( client .get_connection() .map_err(|err| FalkorDBError::RedisError(err.to_string()))?, ), }) } } ``` -------------------------------- ### FalkorDB Client Modules Source: https://docs.rs/falkordb/0.1.11/src/falkordb/value/config.rs Overview of the FalkorDB client modules, including asynchronous and blocking interfaces, connection management, and builder patterns. ```rust client/asynchronous.rs client/blocking.rs client/builder.rs client/mod.rs ``` -------------------------------- ### FalkorDB Client Connection and Query (Synchronous) Source: https://docs.rs/falkordb/0.1.11/falkordb/index Demonstrates how to establish a connection to FalkorDB using the FalkorClientBuilder, select a graph, and execute a Cypher query with a timeout. It also shows how to iterate over the query results. ```rust use falkordb::{FalkorClientBuilder, FalkorConnectionInfo}; // Connect to FalkorDB let connection_info: FalkorConnectionInfo = "falkor://127.0.0.1:6379".try_into() .expect("Invalid connection info"); let client = FalkorClientBuilder::new() .with_connection_info(connection_info) .build() .expect("Failed to build client"); // Select the social graph let mut graph = client.select_graph("social"); // Create 100 nodes and return a handful let mut nodes = graph.query("UNWIND range(0, 100) AS i CREATE (n { v:1 }) RETURN n LIMIT 10") .with_timeout(5000) .execute() .expect("Failed executing query"); // Can also be collected, like any other iterator while let Some(node) = nodes.data.next() { println ! ("{:?}", node); } ``` -------------------------------- ### FalkorDB LazyResultSet Methods Source: https://docs.rs/falkordb/0.1.11/falkordb/struct.LazyResultSet Provides documentation for the methods available on the LazyResultSet struct in the FalkorDB Rust client. These methods allow checking if the result set is empty and getting its length. ```APIDOC LazyResultSet: is_empty() -> bool Checks if the result set is empty. len() -> usize Returns the number of elements in the result set. ``` -------------------------------- ### FalkorSyncClient API Source: https://docs.rs/falkordb/0.1.11/falkordb/struct.FalkorSyncClient Provides methods for interacting with the FalkorDB database using a synchronous client. This includes operations like listing graphs, getting configuration values, and managing connections. ```APIDOC FalkorSyncClient: connection_pool_size() -> u8 Description: Get the max number of connections in the client’s connection pool. Returns: The maximum number of connections as a u8. list_graphs() -> FalkorResult> Description: Return a list of graphs currently residing in the database. Returns: A Vec of Strings, containing the names of available graphs. config_get(config_key: &str) -> FalkorResult> Description: Return the current value of a configuration option in the database. Arguments: config_key: A String representation of a configuration’s key. The config key can also be “*”, which will return ALL the configuration options. Returns: A HashMap where keys are configuration option names (String) and values are their corresponding ConfigValue. Enums: ConfigValue ConstraintStatus ConstraintType EntityType FalkorConnectionInfo FalkorDBError FalkorValue IndexStatus IndexType SchemaType Type Aliases: FalkorResult ``` -------------------------------- ### FalkorDB Client Modules Source: https://docs.rs/falkordb/0.1.11/src/falkordb/response/slowlog_entry.rs Overview of the FalkorDB client modules, including asynchronous and blocking interfaces, connection management, and builder patterns. ```rust client/asynchronous.rs client/blocking.rs client/builder.rs client/mod.rs ``` -------------------------------- ### Rust Trait Implementations (Any, Borrow, BorrowMut) Source: https://docs.rs/falkordb/0.1.11/falkordb/enum.IndexType Documentation for Rust traits Any, Borrow, and BorrowMut as implemented in Falkordb. This includes methods for getting TypeId, immutable borrowing, and mutable borrowing. ```APIDOC fn type_id(&self) -> TypeId Gets the `TypeId` of `self`. fn borrow(&self) -> &T Immutably borrows from an owned value. fn borrow_mut(&mut self) -> &mut T Mutably borrows from an owned value. ``` -------------------------------- ### Rust Iterator enumerate Method Source: https://docs.rs/falkordb/0.1.11/falkordb/struct.LazyResultSet The `enumerate` method creates an iterator that yields pairs of the current iteration count (starting from 0) and the element. This is useful when you need both the index and the value of an element. ```rust fn enumerate(self) -> Enumerate where Self: Sized, ``` -------------------------------- ### FalkorDB Rust Client Overview Source: https://docs.rs/falkordb/0.1.11/src/falkordb/connection/asynchronous.rs This section provides an overview of the FalkorDB Rust client library, version 0.1.11. It includes links to the source code, license information, and related resources. The client is built with asynchronous capabilities. ```Rust Project: /websites/rs_falkordb_0_1_11 Dependencies: - parking_lot ^0.12.3 - redis ^0.28.2 - regex ^1.11.1 - strum ^0.26.3 - thiserror ^2.0.11 - tokio ^1.43.0 (optional) - tracing ^0.1.41 (optional) - approx ^0.5.1 (dev) License: MIT Source Code: https://docs.rs/falkordb/0.1.11/src/falkordb/connection/asynchronous.rs.html Repository: https://github.com/FalkorDB/falkordb-rs Crates.io: https://crates.io/crates/falkordb ``` -------------------------------- ### Get Specific Configuration Value Source: https://docs.rs/falkordb/0.1.11/src/falkordb/client/blocking.rs Shows how to retrieve a specific configuration parameter, such as 'QUERY_MEM_CAPACITY', from the FalkorDB client. It includes error handling and assertions to verify the retrieved configuration value's type and presence. ```rust let config = client.config_get("QUERY_MEM_CAPACITY").expect("Could not get configuration"); assert_eq!(config.len(), 1); assert!(config.contains_key("QUERY_MEM_CAPACITY")); assert_eq!(mem::discriminant(config.get("QUERY_MEM_CAPACITY").unwrap()), mem::discriminant(&ConfigValue::Int64(0))) ``` -------------------------------- ### FalkorClientBuilder API Documentation Source: https://docs.rs/falkordb/0.1.11/falkordb/struct.FalkorClientBuilder Provides a comprehensive overview of the FalkorClientBuilder methods for configuring and creating FalkorDB clients. ```APIDOC FalkorClientBuilder: Methods: new() -> Self Creates a new FalkorClientBuilder for a synchronous client. Returns: A new FalkorClientBuilder instance. new_async() -> Self Creates a new FalkorClientBuilder for an asynchronous client. Returns: A new FalkorClientBuilder instance. with_connection_info(falkor_connection_info: FalkorConnectionInfo) -> Self Provide a connection info for the database connection. Will otherwise use the default connection details. Arguments: falkor_connection_info: The FalkorConnectionInfo to provide. Returns: The consumed and modified self. with_num_connections(num_connections: NonZeroU8) -> Self Specify how large a connection pool to maintain, for concurrent operations. Arguments: num_connections: The number of connections, a non-negative integer, between 1 and 32. Returns: The consumed and modified self. build(self) -> FalkorResult Consume the builder, returning the newly constructed sync client. Returns: A new FalkorSyncClient. build_async(self) -> FalkorResult Consume the builder, returning the newly constructed async client. Returns: A new FalkorAsyncClient. FalkorConnectionInfo: Methods: new(host: &str, port: u16, user: &str, password: &str) -> FalkorConnectionInfo Creates a new FalkorConnectionInfo. Arguments: host: The database host address. port: The database port. user: The username for authentication. password: The password for authentication. Returns: A new FalkorConnectionInfo instance. ``` -------------------------------- ### FalkorDB Get Configuration Value Source: https://docs.rs/falkordb/0.1.11/src/falkordb/client/asynchronous.rs Retrieves the current value of a specific configuration option in the FalkorDB database. It accepts a configuration key as input, or '*' to fetch all configuration options. The result is returned as a HashMap. ```rust /// Return the current value of a configuration option in the database. /// /// # Arguments /// * `config_Key`: A [`String`] representation of a configuration's key. /// The config key can also be "*", which will return ALL the configuration options. /// /// # Returns /// A [`HashMap`] comprised of [`String`] keys, and [`ConfigValue`] values. #[cfg_attr( feature = "tracing", tracing::instrument(name = "Get Config Value", skip_all, level = "info") )] pub async fn get_config_value(&self, config_Key: String) -> FalkorResult> { self.borrow_connection() .await? .execute_command(None, "CONFIG.GET", Some(redis::CmdArgs::from(vec![config_Key])), None) .await .and_then(redis_value_as_config_hashmap) } ``` -------------------------------- ### FalkorDB Client Modules Source: https://docs.rs/falkordb/0.1.11/src/falkordb/connection_info/mod.rs Overview of the FalkorDB client modules, including asynchronous and blocking interfaces, connection management, and builder patterns. ```rust client/asynchronous.rs client/blocking.rs client/builder.rs client/mod.rs ``` -------------------------------- ### Parse Point Data with FalkorDB Source: https://docs.rs/falkordb/0.1.11/src/falkordb/parser/mod.rs Illustrates parsing a Redis array containing two simple strings representing coordinates into a FalkorValue::Point. This example verifies that the string coordinates are correctly converted to floating-point numbers. ```rust let res = parse_type( ParserTypeMarker::Point, redis::Value::Array(vec![ redis::Value::SimpleString("102.0".to_string()), redis::Value::SimpleString("15.2".to_string()), ]), graph.get_graph_schema_mut(), ); assert!(res.is_ok()); let falkor_point = res.unwrap(); ``` -------------------------------- ### FalkorDB Rust Client Dependencies Source: https://docs.rs/falkordb/0.1.11/src/falkordb/response/slowlog_entry.rs Lists the direct dependencies required for the falkordb Rust client. These include crates for asynchronous operations (tokio), regular expressions, and error handling. ```Rust parking_lot ^0.12.3 redis ^0.28.2 regex ^1.11.1 strum ^0.26.3 thiserror ^2.0.11 tokio ^1.43.0 (optional) tracing ^0.1.41 (optional) approx ^0.5.1 (dev) ``` -------------------------------- ### FalkorDB Client Modules Source: https://docs.rs/falkordb/0.1.11/src/falkordb/client/mod.rs Overview of the FalkorDB client modules, including asynchronous and blocking interfaces, connection management, and builder patterns. ```rust client/asynchronous.rs client/blocking.rs client/builder.rs client/mod.rs ``` -------------------------------- ### FalkorDB Client Modules Source: https://docs.rs/falkordb/0.1.11/src/falkordb/lib.rs Overview of the FalkorDB client modules, including asynchronous and blocking interfaces, connection management, and builder patterns. ```rust client/asynchronous.rs client/blocking.rs client/builder.rs client/mod.rs ``` -------------------------------- ### Get Async Connection (Tokio) Source: https://docs.rs/falkordb/0.1.11/src/falkordb/client/mod.rs Retrieves an asynchronous connection to FalkorDB using Tokio. This function handles different client provider configurations, including Redis with or without Sentinel, and maps potential Redis errors to FalkorDB errors. ```rust pub(crate) async fn get_async_connection(&mut self) -> FalkorResult { Ok(match self { FalkorClientProvider::Redis { sentinel: Some(sentinel), .. } => FalkorAsyncConnection::Redis( sentinel .get_async_connection() .await .map_err(|err| FalkorDBError::RedisError(err.to_string()))?, ), FalkorClientProvider::Redis { client, .. } => FalkorAsyncConnection::Redis( client .get_multiplexed_tokio_connection() .await .map_err(|err| FalkorDBError::RedisError(err.to_string()))?, ), #[cfg(test)] FalkorClientProvider::None => Err(FalkorDBError::UnavailableProvider)?, }) } ``` -------------------------------- ### Get Sentinel Client (Async) Source: https://docs.rs/falkordb/0.1.11/src/falkordb/client/mod.rs Retrieves an asynchronous Sentinel client for FalkorDB using Tokio. Similar to the synchronous version, it verifies the connection is to a Redis Sentinel and then fetches master information via the 'SENTINEL MASTERS' command to initialize the client. ```rust pub(crate) async fn get_sentinel_client_async( &mut self, connection_info: &redis::ConnectionInfo, ) -> FalkorResult> { let mut conn = self.get_async_connection().await?; if !conn.check_is_redis_sentinel().await? { return Ok(None); } conn.execute_command(None, "SENTINEL", Some("MASTERS"), None) .await .and_then(redis_value_as_vec) .and_then(|sentinel_masters| { self.get_sentinel_client_common(connection_info, sentinel_masters) }) } ``` -------------------------------- ### FalkorDB: Try From Address and Port Source: https://docs.rs/falkordb/0.1.11/src/falkordb/connection_info/mod.rs Tests the `try_from` method for creating `FalkorConnectionInfo` from a host and port tuple. It asserts that the conversion is successful and the address is formatted correctly. ```rust let res = FalkorConnectionInfo::try_from(("127.0.0.1", 1234)); assert!(res.is_ok()); assert_eq!(res.unwrap().address(), "127.0.0.1:1234".to_string()); ``` -------------------------------- ### FalkorDB Client Modules Source: https://docs.rs/falkordb/0.1.11/src/falkordb/graph/mod.rs Overview of the FalkorDB client modules, including asynchronous and blocking interfaces, connection management, and builder patterns. ```rust client/asynchronous.rs client/blocking.rs client/builder.rs client/mod.rs ``` -------------------------------- ### Create and Drop Unique Constraint Source: https://docs.rs/falkordb/0.1.11/src/falkordb/graph/blocking.rs Shows how to create and remove a unique constraint in FalkorDB. This ensures that a specific property or set of properties has unique values for all entities of a given type. The example demonstrates setting up a unique constraint on a node. ```rust let mut graph = open_empty_test_graph("test_unique_constraint"); graph .inner .create_unique_constraint(EntityType::Node, "person", &["name"]) .expect("Could not create unique constraint"); graph .inner .drop_constraint( ConstraintType::Unique, EntityType::Node, "person", &["name"], ) .expect("Could not drop unique constraint"); ``` -------------------------------- ### Create Synchronous Test Client Source: https://docs.rs/falkordb/0.1.11/src/falkordb/lib.rs A utility function to create a new synchronous FalkorDB client. It utilizes `FalkorClientBuilder` to configure and build the client, expecting a successful creation. This is a common setup for initiating synchronous interactions with the database. ```rust pub(crate) fn create_test_client() -> FalkorSyncClient { FalkorClientBuilder::new() .build() .expect("Could not create client") } ``` -------------------------------- ### FalkorDB Rust Client Dependencies Source: https://docs.rs/falkordb/0.1.11/src/falkordb/response/execution_plan.rs Lists the direct dependencies for the falkorDB Rust client version 0.1.11. This includes core libraries for asynchronous operations, Redis interaction, regular expressions, string manipulation, error handling, and optional features for Tokio and tracing. ```rust parking_lot = "^0.12.3" redis = "^0.28.2" regex = "^1.11.1" strum = "^0.26.3" thiserror = "^2.0.11" tokio = { version = "^1.43.0", optional = true } tracing = { version = "^0.1.41", optional = true } ``` -------------------------------- ### FalkorDB Client Modules Source: https://docs.rs/falkordb/0.1.11/src/falkordb/connection/asynchronous.rs Overview of the FalkorDB client modules, including asynchronous and blocking interfaces, connection management, and builder patterns. ```rust client/asynchronous.rs client/blocking.rs client/builder.rs client/mod.rs ``` -------------------------------- ### Get Refresh Command for Schema Type Source: https://docs.rs/falkordb/0.1.11/src/falkordb/graph_schema/mod.rs Returns the appropriate Redis command string to refresh a specific type of schema information (Labels, Properties, or Relationship Types). This is used internally by the FalkorDB client to fetch schema details. ```rust pub(crate) fn get_refresh_command(schema_type: SchemaType) -> &'static str { match schema_type { SchemaType::Labels => "DB.LABELS", SchemaType::Properties => "DB.PROPERTYKEYS", SchemaType::Relationships => "DB.RELATIONSHIPTYPES", } } ``` -------------------------------- ### Parse Map Structure Source: https://docs.rs/falkordb/0.1.11/src/falkordb/parser/mod.rs This example shows how to parse a Redis Value representing a map. It uses `ParserTypeMarker::Map` to indicate the expected type and provides a sample array of key-value pairs. This is useful for handling dictionary-like data structures returned from the database. ```rust let res = parse_type( ParserTypeMarker::Map, redis::Value::Array(vec![ redis::Value::SimpleString("key0".to_string()), redis::Value::Int(52), redis::Value::Array(vec![]), redis::Value::Array(vec![ redis::Value::Int(101), redis::Value::Int(1), redis::Value::Int(52), redis::Value::Int(53), redis::Value::Array(vec![]) ]) ]) ); ``` -------------------------------- ### Asynchronous FalkorDB Client Creation Source: https://docs.rs/falkordb/0.1.11/src/falkordb/client/builder.rs Shows the creation of an asynchronous FalkorDB client. This involves creating a client instance, providing connection details, and awaiting the client creation. ```rust FalkorAsyncClient::create(client, connection_info, self.num_connections.get()).await ``` -------------------------------- ### Convert Redis Value to Typed String Vector Source: https://docs.rs/falkordb/0.1.11/src/falkordb/parser/mod.rs Converts a redis::Value into a FalkorResult containing a Vec. It first attempts to get a typed value and then converts it into a vector of strings. If the type marker is not an Array or conversion fails, it returns a ParsingArray error. ```rust pub(crate) fn redis_value_as_typed_string_vec(value: redis::Value) -> FalkorResult> { type_val_from_value(value) .and_then(|(type_marker, val)| { if type_marker == ParserTypeMarker::Array { redis_value_as_vec(val) } else { Err(FalkorDBError::ParsingArray) } }) .map(|val_vec| { val_vec .into_iter() .flat_map(redis_value_as_string) .collect() }) } ```