### Connecting to a Database Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/struct.ConnectParams.html Example of initializing ConnectParams and establishing a connection to a local database. ```rust use rsmgclient::{ConnectParams, Connection}; let connect_params = ConnectParams { host: Some(String::from("localhost")), ..Default::default() }; let mut connection = Connection::connect(&connect_params)?; ``` -------------------------------- ### Connect and execute query Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/struct.Connection.html Demonstrates establishing a connection using ConnectParams and executing a Cypher query. ```rust use rsmgclient::{ConnectParams, Connection}; let connect_params = ConnectParams { host: Some(String::from("localhost")), ..Default::default() }; let mut connection = Connection::connect(&connect_params)?; let query = "CREATE (u:User {name: 'Alice'})-[l:Likes]->(m:Software {name: 'Memgraph'}) RETURN u, l, m"; connection.execute(query, None)?; let records = connection.fetchall()?; for value in &records[0].values { println!("{}", value); } connection.commit()?; ``` -------------------------------- ### Connection::connect Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/struct.Connection.html Establishes a new database connection using the provided connection parameters. ```APIDOC ## Connection::connect ### Description Creates a new connection to the database using the specified connection parameters. ### Signature `pub fn connect(params: &ConnectParams) -> Result` ``` -------------------------------- ### Connection::connect Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/struct.Connection.html Creates a connection to the database using the provided connection parameters. ```APIDOC ## pub fn connect(param_struct: &ConnectParams) -> Result ### Description Creates a connection to the database using provided connection parameters. Returns a Connection object if successful, otherwise returns an error. ### Parameters - **param_struct** (&ConnectParams) - Required - The connection parameters used to establish the database connection. ``` -------------------------------- ### Connection::execute Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/struct.Connection.html Executes a query with optional parameters and returns the column names. ```APIDOC ## pub fn execute(&mut self, query: &str, params: Option<&HashMap>) -> Result, MgError> ### Description Executes the provided query using optional parameters and returns the names of the columns. Records must be fetched subsequently using fetch methods. ``` -------------------------------- ### Connection::fetch methods Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/struct.Connection.html Methods for retrieving query results from the connection. ```APIDOC ## Fetch Methods ### pub fn fetchone(&mut self) -> Result, MgError> Returns the next row of query results or None if no more data is available. ### pub fn fetchmany(&mut self, size: Option) -> Result, MgError> Returns the next set of rows. The number of rows is determined by the `size` parameter or the `arraysize` attribute. ### pub fn fetchall(&mut self) -> Result, MgError> Returns all remaining rows of the query results. ``` -------------------------------- ### Connection::fetchall Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/struct.Connection.html Fetches all records resulting from the previously executed query. ```APIDOC ## Connection::fetchall ### Description Retrieves all records from the current result set. ### Signature `pub fn fetchall(&mut self) -> Result, Error>` ``` -------------------------------- ### ConnectParams Struct Definition Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/struct.ConnectParams.html The structure definition for database connection parameters. ```rust pub struct ConnectParams { pub port: u16, pub host: Option, pub address: Option, pub username: Option, pub password: Option, pub client_name: String, pub sslmode: SSLMode, pub sslcert: Option, pub sslkey: Option, pub trust_callback: Option, pub lazy: bool, pub autocommit: bool, } ``` -------------------------------- ### Duration Creation Methods Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/struct.Duration.html Methods to instantiate a new Duration object from specific time units. ```APIDOC ### pub fn days(days: i64) -> Self A duration of `days` whole days (each treated as 86 400 seconds). ### pub fn seconds(seconds: i64) -> Self A duration of `seconds` whole seconds. ### pub fn nanoseconds(nanoseconds: i64) -> Self A duration of `nanoseconds` nanoseconds. ``` -------------------------------- ### Connection::execute Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/struct.Connection.html Executes a Cypher query against the database connection. ```APIDOC ## Connection::execute ### Description Executes a given query string with optional parameters. ### Signature `pub fn execute(&mut self, query: &str, params: Option>) -> Result<(), Error>` ``` -------------------------------- ### LocalDateTime::new Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/struct.LocalDateTime.html Creates a new LocalDateTime instance from individual date and time components. Returns an error if the provided components form an invalid date or time. ```APIDOC ## pub fn new(year: i16, month: i8, day: i8, hour: i8, minute: i8, second: i8, nanosecond: i32) -> Result ### Description Creates a datetime from its components, erroring on invalid input. ### Parameters - **year** (i16) - The year component. - **month** (i8) - The month component. - **day** (i8) - The day component. - **hour** (i8) - The hour component. - **minute** (i8) - The minute component. - **second** (i8) - The second component. - **nanosecond** (i32) - The sub-second component in nanoseconds (0..=999_999_999). ``` -------------------------------- ### LocalDateTime Accessor Methods Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/struct.LocalDateTime.html Methods to retrieve individual components of a LocalDateTime instance. ```APIDOC ## Accessor Methods - **year() -> i16**: Returns the year. - **month() -> i8**: Returns the month. - **day() -> i8**: Returns the day. - **hour() -> i8**: Returns the hour. - **minute() -> i8**: Returns the minute. - **second() -> i8**: Returns the second. - **nanosecond() -> i32**: Returns the nanosecond component. ``` -------------------------------- ### Duration Query Methods Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/struct.Duration.html Methods to retrieve the total number of specific time units contained within the duration. ```APIDOC ### pub fn num_weeks(&self) -> i64 Total number of whole weeks in the duration. ### pub fn num_days(&self) -> i64 Total number of whole days in the duration. ### pub fn num_hours(&self) -> i64 Total number of whole hours in the duration. ### pub fn num_seconds(&self) -> i64 Total number of whole seconds in the duration. ### pub fn num_nanoseconds(&self) -> i64 Total number of nanoseconds in the duration. ``` -------------------------------- ### Define Connection struct Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/struct.Connection.html The internal structure definition for the Connection type. ```rust pub struct Connection { /* private fields */ } ``` -------------------------------- ### Define Record struct Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/struct.Record.html The Record struct definition showing its internal storage of database values. ```rust pub struct Record { pub values: Vec, } ``` -------------------------------- ### Connection::transaction management Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/struct.Connection.html Methods for managing database transactions. ```APIDOC ## Transaction Methods ### pub fn commit(&mut self) -> Result<(), MgError> Commits any pending transaction to the database. ### pub fn rollback(&mut self) -> Result<(), MgError> Rolls back any pending transaction to the database. ``` -------------------------------- ### Point3D Struct Definition Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/struct.Point3D.html The structure definition for Point3D, containing spatial coordinate fields and SRID. ```rust pub struct Point3D { pub srid: u16, pub x_longitude: f64, pub y_latitude: f64, pub z_height: f64, } ``` -------------------------------- ### DateTime Struct Definition Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/struct.DateTime.html The structure definition for DateTime, containing date, time, and timezone components. ```rust pub struct DateTime { pub year: i32, pub month: u32, pub day: u32, pub hour: u32, pub minute: u32, pub second: u32, pub nanosecond: u32, pub time_zone_offset_seconds: i32, pub time_zone_id: Option, } ``` -------------------------------- ### Path Struct Definition Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/struct.Path.html The structure definition for Path, containing counts and vectors for nodes and relationships. ```rust pub struct Path { pub node_count: u32, pub relationship_count: u32, pub nodes: Vec, pub relationships: Vec, } ``` -------------------------------- ### Node Struct Definition Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/struct.Node.html The primary structure definition for a node, including its identifier, labels, and property map. ```rust pub struct Node { pub id: i64, pub label_count: u32, pub labels: Vec, pub properties: HashMap, } ``` -------------------------------- ### Connection::commit Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/struct.Connection.html Commits the current transaction. ```APIDOC ## Connection::commit ### Description Commits the changes made during the current transaction. ### Signature `pub fn commit(&mut self) -> Result<(), Error>` ``` -------------------------------- ### QueryParam Enum Definition Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/enum.QueryParam.html The definition of the QueryParam enum showing all supported variants for query parameter values. ```rust pub enum QueryParam { Show 13 variants Null, Bool(bool), Int(i64), Float(f64), String(String), Date(Date), LocalTime(LocalTime), LocalDateTime(LocalDateTime), Duration(Duration), Point2D(Point2D), Point3D(Point3D), List(Vec), Map(HashMap), } ``` -------------------------------- ### Point2D Struct Definition Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/struct.Point2D.html The structure definition for Point2D, containing spatial coordinate data. ```rust pub struct Point2D { pub srid: u16, pub x_longitude: f64, pub y_latitude: f64, } ``` -------------------------------- ### Define SSLMode Enum Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/enum.SSLMode.html The SSLMode enum provides two variants to control SSL negotiation during connection. ```rust pub enum SSLMode { Disable, Require, } ``` -------------------------------- ### ConnectionStatus Enum Definition Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/enum.ConnectionStatus.html The definition of the ConnectionStatus enum with its variants and their corresponding integer values. ```rust #[repr(u8)] pub enum ConnectionStatus { Ready = 0, InTransaction = 1, Executing = 2, Fetching = 3, Closed = 4, Bad = 5, } ``` -------------------------------- ### Define TrustCallback type alias Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/type.TrustCallback.html Represents a pointer to a function used for SSL trust callbacks. ```rust pub type TrustCallback = *const dyn Fn(&String, &String, &String, &String) -> i32; ``` -------------------------------- ### Value Enum Definition Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/enum.Value.html The definition of the Value enum showing all 18 supported variants for Bolt protocol data types. ```rust pub enum Value { Show 18 variants Null, Bool(bool), Int(i64), Float(f64), String(String), List(Vec), Date(Date), LocalTime(LocalTime), LocalDateTime(LocalDateTime), DateTime(DateTime), Duration(Duration), Point2D(Point2D), Point3D(Point3D), Map(HashMap), Node(Node), Relationship(Relationship), UnboundRelationship(UnboundRelationship), Path(Path), } ``` -------------------------------- ### UnboundRelationship struct definition Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/struct.UnboundRelationship.html The structure definition for UnboundRelationship, containing an ID, type, and a map of properties. ```rust pub struct UnboundRelationship { pub id: i64, pub type_: String, pub properties: HashMap, } ``` -------------------------------- ### MgError Enum Definition Source: https://docs.rs/rsmgclient/4.0.0/rsmgclient/enum.MgError.html The structure of the MgError enum, detailing all possible error variants and their associated data fields. ```rust pub enum MgError { Connection(String), QueryExecution(String), InvalidParameter { parameter: String, reason: String, }, NullByte { parameter: String, }, InvalidTimestamp, InvalidState { operation: String, state: String, }, Ffi(String), } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.