# `surql-definition-core` `surql-definition-core` is a Rust library that provides core utilities and traits for generating SurrealDB schema queries. The crate includes a trait for schema generation and a utility function for converting strings to snake case. This crate is used by the `surql-definition-macros` crate to generate SurrealDB table and field definitions. ## Table of Contents 1. [Features](#features) 2. [Installation](#installation) 3. [Usage](#usage) 4. [Examples](#examples) 1. [Generating a SurrealDB Schema Query](#generating-a-surrealdb-schema-query) 2. [Converting Strings to Snake Case](#converting-strings-to-snake-case) 5. [License](#license) 6. [Links](#links) ## Features - Provides a `SurQLSchemaProducer` trait for generating SurrealDB schema queries. - Includes a utility function `to_snake_case` for converting strings to snake case. ## Installation Add `surql-definition-core` to your `Cargo.toml`: ```toml [dependencies] surql-definition-core = "0.2.1" ``` ## Usage To use `surql-definition-core`, import the trait or utility function as needed: ```rust use surql_definition_core::{SurQLSchemaProducer, to_snake_case}; ``` ## Examples ### Generating a SurrealDB Schema Query Implement the `SurQLSchemaProducer` trait to define a schema query for a struct: ```rust use surql_definition_core::SurQLSchemaProducer; struct MyTable; impl SurQLSchemaProducer for MyTable { fn schema_query() -> &'static str { "DEFINE TABLE my_table;" } } assert_eq!(MyTable::schema_query(), "DEFINE TABLE my_table;"); ``` ### Converting Strings to Snake Case Use the `to_snake_case` function to convert a string to snake case: ```rust use surql_definition_core::to_snake_case; assert_eq!(to_snake_case("HelloWorld"), "hello_world"); assert_eq!(to_snake_case("snake_case"), "snake_case"); assert_eq!(to_snake_case("CamelCase123"), "camel_case_123"); ``` ## License This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. ## Links - [Crate on crates.io](https://crates.io/crates/surql-definition-core) - [Documentation](https://docs.rs/surql-definition-core) - [Repository](https://github.com/kochmaxence/surql-definition-macros) - [surql-definition-macros](https://github.com/kochmaxence/surql-definition-macros)