The base commit
This commit is contained in:
commit
dfe05b2456
27
.editorconfig
Normal file
27
.editorconfig
Normal file
@ -0,0 +1,27 @@
|
||||
# https://EditorConfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.rs]
|
||||
max_line_length = 100
|
||||
|
||||
[*.{py,pyi}]
|
||||
max_line_length = 100
|
||||
|
||||
[*.md]
|
||||
max_line_length = 150
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.sh]
|
||||
indent_size = 2
|
||||
|
||||
[*.{yaml,yml}]
|
||||
indent_size = 2
|
||||
53
.gitattributes
vendored
Normal file
53
.gitattributes
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
# Normalize all text files to LF line endings
|
||||
* text=auto eol=lf
|
||||
|
||||
# Go source files
|
||||
*.go text
|
||||
*.mod text
|
||||
*.sum text
|
||||
|
||||
# Markdown and documentation files
|
||||
*.md text
|
||||
*.rst text
|
||||
|
||||
# JSON, YAML, and configuration files
|
||||
*.json text
|
||||
*.yaml text
|
||||
*.yml text
|
||||
*.toml text
|
||||
|
||||
# Shell scripts
|
||||
*.sh text eol=lf
|
||||
|
||||
# Static files
|
||||
*.html text
|
||||
*.css text
|
||||
*.js text
|
||||
*.svg text
|
||||
*.xml text
|
||||
|
||||
# Large assets (use Git LFS)
|
||||
*.png filter=lfs diff=lfs merge=lfs -text
|
||||
*.jpg filter=lfs diff=lfs merge=lfs -text
|
||||
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
||||
*.gif filter=lfs diff=lfs merge=lfs -text
|
||||
*.ico filter=lfs diff=lfs merge=lfs -text
|
||||
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
||||
*.mov filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
|
||||
# Font files (binary, tracked via LFS)
|
||||
*.ttf filter=lfs diff=lfs merge=lfs -text
|
||||
*.woff filter=lfs diff=lfs merge=lfs -text
|
||||
*.woff2 filter=lfs diff=lfs merge=lfs -text
|
||||
|
||||
# Build artifacts (binary, optional LFS tracking)
|
||||
*.exe filter=lfs diff=lfs merge=lfs -text
|
||||
*.dll filter=lfs diff=lfs merge=lfs -text
|
||||
*.so filter=lfs diff=lfs merge=lfs -text
|
||||
*.out filter=lfs diff=lfs merge=lfs -text
|
||||
*.a filter=lfs diff=lfs merge=lfs -text
|
||||
*.o filter=lfs diff=lfs merge=lfs -text
|
||||
85
.gitignore
vendored
Normal file
85
.gitignore
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
# Python specific
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# Virtual environments
|
||||
.env/
|
||||
env/
|
||||
.venv/
|
||||
venv/
|
||||
|
||||
# Packaging and distribution files
|
||||
.Python
|
||||
build/
|
||||
dist/
|
||||
*.egg-info/
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# Dependency directories
|
||||
develop-eggs/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
.installed.cfg
|
||||
|
||||
# Test and coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
|
||||
# IDE specific files and directories
|
||||
.idea/
|
||||
*.iml
|
||||
.vscode/
|
||||
|
||||
# Jupyter Notebook files
|
||||
.ipynb_checkpoints
|
||||
|
||||
# Temporary files created by editors and the system and folders to ignore
|
||||
*.swp
|
||||
*~
|
||||
*.bak
|
||||
*.tmp
|
||||
temp/
|
||||
tmp/
|
||||
|
||||
# Database files (SQLite, DuckDB, etc.)
|
||||
*.duckdb
|
||||
*.db
|
||||
*.wal
|
||||
*.sqlite
|
||||
|
||||
# Dependency lock files (uncomment to ignore)
|
||||
poetry.lock
|
||||
|
||||
# Rust specific
|
||||
/target/
|
||||
.cargo-ok
|
||||
cobertura.xml
|
||||
tarpaulin-report.html
|
||||
|
||||
# Comment out the next line if you want to checkin your lock file for Cargo
|
||||
Cargo.lock
|
||||
|
||||
# Miscellaneous files and directories to ignore
|
||||
# Add any additional file patterns a directory names that should be ignored down here
|
||||
.DS_Store
|
||||
tests/testdata/*.csv
|
||||
tests/testdata/*.parquet
|
||||
.benchmarks
|
||||
.env
|
||||
43
.pre-commit-config.yaml
Normal file
43
.pre-commit-config.yaml
Normal file
@ -0,0 +1,43 @@
|
||||
default_stages: [ pre-push ]
|
||||
fail_fast: false
|
||||
exclude: '^(benches/|tests/|examples/|docs/)'
|
||||
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v5.0.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
args: [ --markdown-linebreak-ext=md ]
|
||||
- id: end-of-file-fixer
|
||||
- id: mixed-line-ending
|
||||
- id: check-merge-conflict
|
||||
- id: check-added-large-files
|
||||
- id: detect-private-key
|
||||
- id: check-yaml
|
||||
- id: check-toml
|
||||
- id: check-json
|
||||
- id: check-docstring-first
|
||||
- id: pretty-format-json
|
||||
args: [ --autofix, --no-sort-keys ]
|
||||
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: format
|
||||
name: Format Code
|
||||
entry: make format
|
||||
language: system
|
||||
pass_filenames: false
|
||||
stages: [ pre-commit ]
|
||||
|
||||
- id: lint
|
||||
name: Check Code Style
|
||||
entry: make lint
|
||||
language: system
|
||||
pass_filenames: false
|
||||
stages: [ pre-commit ]
|
||||
|
||||
- id: test
|
||||
name: Run Tests
|
||||
entry: make nexttest
|
||||
language: system
|
||||
pass_filenames: false
|
||||
201
LICENSE-APACHE
Normal file
201
LICENSE-APACHE
Normal file
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
21
LICENSE-MIT
Normal file
21
LICENSE-MIT
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Obsidian Systems LLC
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
140
Makefile
Normal file
140
Makefile
Normal file
@ -0,0 +1,140 @@
|
||||
# Load environment variables from .env file
|
||||
ifneq (,$(wildcard ./.env))
|
||||
include .env
|
||||
export $(shell sed 's/=.*//' .env)
|
||||
else
|
||||
$(warning .env file not found. Environment variables not loaded.)
|
||||
endif
|
||||
|
||||
# Variables
|
||||
PROJ_REPO = github.com/habedi/template-rust-project
|
||||
BINARY_NAME := $(or $(PROJ_BINARY), $(notdir $(PROJ_REPO)))
|
||||
BINARY := target/release/$(BINARY_NAME)
|
||||
PATH := /snap/bin:$(PATH)
|
||||
DEBUG_PROJ := 0
|
||||
RUST_BACKTRACE := 1
|
||||
ASSET_DIR := assets
|
||||
TEST_DATA_DIR := tests/testdata
|
||||
SHELL := /bin/bash
|
||||
|
||||
# Default target
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
.PHONY: help
|
||||
help: ## Show help messages for all available targets
|
||||
@grep -E '^[a-zA-Z_-]+:.*## .*$$' Makefile | \
|
||||
awk 'BEGIN {FS = ":.*## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
||||
|
||||
.PHONY: format
|
||||
format: ## Format Rust files
|
||||
@echo "Formatting Rust files..."
|
||||
@cargo fmt
|
||||
|
||||
.PHONY: test
|
||||
test: format ## Run the tests
|
||||
@echo "Running tests..."
|
||||
@DEBUG_PROJ=$(DEBUG_PROJ) RUST_BACKTRACE=$(RUST_BACKTRACE) cargo test --all-targets --workspace -- --nocapture
|
||||
|
||||
.PHONY: coverage
|
||||
coverage: format ## Generate test coverage report
|
||||
@echo "Generating test coverage report..."
|
||||
@DEBUG_PROJ=$(DEBUG_PROJ) cargo tarpaulin --out Xml --out Html
|
||||
|
||||
.PHONY: build
|
||||
build: format ## Build the binary for the current platform
|
||||
@echo "Building the project..."
|
||||
@DEBUG_PROJ=$(DEBUG_PROJ) cargo build --release
|
||||
|
||||
.PHONY: run
|
||||
run: build ## Build and run the binary
|
||||
@echo "Running the $(BINARY) binary..."
|
||||
@DEBUG_PROJ=$(DEBUG_PROJ) ./$(BINARY)
|
||||
|
||||
.PHONY: clean
|
||||
clean: ## Remove generated and temporary files
|
||||
@echo "Cleaning up..."
|
||||
@cargo clean
|
||||
@rm -f $(ASSET_DIR)/*.svg && echo "Removed SVG files; might want to run 'make figs' to regenerate them."
|
||||
|
||||
.PHONY: install-snap
|
||||
install-snap: ## Install a few dependencies using Snapcraft
|
||||
@echo "Installing the snap package..."
|
||||
@sudo apt-get update
|
||||
@sudo apt-get install -y snapd graphviz wget
|
||||
@sudo snap refresh
|
||||
@sudo snap install rustup --classic
|
||||
|
||||
.PHONY: install-deps
|
||||
install-deps: install-snap ## Install development dependencies
|
||||
@echo "Installing dependencies..."
|
||||
@rustup component add rustfmt clippy
|
||||
@cargo install cargo-tarpaulin
|
||||
@cargo install cargo-audit
|
||||
@cargo install cargo-careful
|
||||
@cargo install cargo-nextest
|
||||
|
||||
.PHONY: lint
|
||||
lint: format ## Run the linters
|
||||
@echo "Linting Rust files..."
|
||||
@DEBUG_PROJ=$(DEBUG_PROJ) cargo clippy -- -D warnings -D clippy::unwrap_used -D clippy::expect_used
|
||||
|
||||
.PHONY: publish
|
||||
publish: ## Publish the package to crates.io (requires CARGO_REGISTRY_TOKEN to be set)
|
||||
@echo "Publishing the package to Cargo registry..."
|
||||
@cargo publish --token $(CARGO_REGISTRY_TOKEN)
|
||||
|
||||
.PHONY: bench
|
||||
bench: ## Run the benchmarks
|
||||
@echo "Running benchmarks..."
|
||||
@DEBUG_PROJ=$(DEBUG_PROJ) cargo bench
|
||||
|
||||
.PHONY: audit
|
||||
audit: ## Run security audit on Rust dependencies
|
||||
@echo "Running security audit..."
|
||||
@cargo audit
|
||||
|
||||
.PHONY: rust-careful
|
||||
careful: ## Run security checks on Rust code
|
||||
@echo "Running security checks..."
|
||||
@cargo careful
|
||||
|
||||
.PHONY: docs
|
||||
docs: format ## Generate the documentation
|
||||
@echo "Generating documentation..."
|
||||
@cargo doc --no-deps --document-private-items
|
||||
|
||||
.PHONE: figs
|
||||
figs: ## Generate the figures in the assets directory
|
||||
@echo "Generating figures..."
|
||||
@$(SHELL) $(ASSET_DIR)/make_figures.sh $(ASSET_DIR)
|
||||
|
||||
.PHONY: fix-lint
|
||||
fix-lint: ## Fix the linter warnings
|
||||
@echo "Fixing linter warnings..."
|
||||
@cargo clippy --fix --allow-dirty --allow-staged --all-targets --workspace --all-features -- -D warnings -D clippy::unwrap_used -D clippy::expect_used
|
||||
|
||||
.PHONY: testdata
|
||||
testdata: ## Download the datasets used in tests
|
||||
@echo "Downloading test data..."
|
||||
@$(SHELL) $(TEST_DATA_DIR)/download_datasets.sh $(TEST_DATA_DIR)
|
||||
|
||||
.PHONY: nextest
|
||||
nextest: ## Run tests using nextest
|
||||
@echo "Running tests using nextest..."
|
||||
@DEBUG_PROJ=$(DEBUG_PROJ) RUST_BACKTRACE=$(RUST_BACKTRACE) cargo nextest run
|
||||
|
||||
.PHONY: setup-hooks
|
||||
setup-hooks: ## Install Git hooks (pre-commit and pre-push)
|
||||
@echo "Setting up Git hooks..."
|
||||
@if ! command -v pre-commit &> /dev/null; then \
|
||||
echo "pre-commit not found. Please install it using 'pip install pre-commit'"; \
|
||||
exit 1; \
|
||||
fi
|
||||
@pre-commit install --hook-type pre-commit
|
||||
@pre-commit install --hook-type pre-push
|
||||
@pre-commit install-hooks
|
||||
|
||||
.PHONY: test-hooks
|
||||
test-hooks: ## Test Git hooks on all files
|
||||
@echo "Testing Git hooks..."
|
||||
@pre-commit run --all-files --show-diff-on-failure
|
||||
12
README.md
Normal file
12
README.md
Normal file
@ -0,0 +1,12 @@
|
||||
## Integrations
|
||||
|
||||
---
|
||||
|
||||
To be added.
|
||||
|
||||
### License
|
||||
|
||||
This project is licensed under either of these:
|
||||
|
||||
* MIT License (see [LICENSE-MIT](LICENSE-MIT))
|
||||
* Apache License, Version 2.0 (see [LICENSE-APACHE](LICENSE-APACHE))
|
||||
113
haskell/notes/001-garnet.md
Normal file
113
haskell/notes/001-garnet.md
Normal file
@ -0,0 +1,113 @@
|
||||
# Garnet Findings
|
||||
|
||||
Date: 2026-03-24
|
||||
|
||||
Garnet repository: https://code.obsidian.systems/patrickaldis/garnet
|
||||
|
||||
## Summary
|
||||
|
||||
Garnet is a proof-of-concept for Rust/Haskell interop.
|
||||
|
||||
The repo is testing a specific pipeline:
|
||||
|
||||
Rust exports a C ABI -> `cbindgen` emits a header -> `hs-bindgen` produces Haskell bindings -> hand-written Haskell wrappers clean up the API.
|
||||
|
||||
It succeeds as a demo. It does not read as production-ready infrastructure.
|
||||
|
||||
## What It Contains
|
||||
|
||||
- `./tmp/garnet/rust/lib.rs` - Rust FFI examples: strings, structs, enums, arithmetic, recursive trees.
|
||||
- `./tmp/garnet/rust/build.rs` - header generation plus a local patch for `hs-bindgen` compatibility.
|
||||
- `./tmp/garnet/lib/GarnetRs/Raw.hs` - low-level binding generation from the generated header.
|
||||
- `./tmp/garnet/lib/GarnetRs/Wrapped.hs` - Haskell-facing wrapper types and conversions.
|
||||
- `./tmp/garnet/exe/Main.hs` - demo executable that exercises the bridge.
|
||||
- `./tmp/garnet/build` - custom build glue for Cargo and Cabal.
|
||||
|
||||
## Review
|
||||
|
||||
The project makes the intended architecture clear. Separating raw bindings from the wrapper layer is the right call, and the examples are broad enough
|
||||
to be useful. This is more than a toy "add two numbers" demo.
|
||||
|
||||
That said, the repo still looks early. The build is custom, the dependency stack is pinned to git revisions, and the Rust build script contains a
|
||||
workaround for upstream tooling issues. That combination is acceptable in an experiment, but it is a weak base for a maintained integration layer.
|
||||
|
||||
The biggest limitation is that code generation does not remove the hard part. The Haskell side still needs manual wrapper code to turn raw bindings
|
||||
into something ergonomic. The repo proves that the pipeline works, but it also shows that the pipeline is not yet cheap.
|
||||
|
||||
## Pros
|
||||
|
||||
- The architecture is clean enough to follow.
|
||||
- The examples cover realistic FFI shapes, not just trivial functions.
|
||||
- The split between generated and hand-written code is sensible.
|
||||
- The repo is small enough to serve as a reference implementation.
|
||||
|
||||
## Cons
|
||||
|
||||
- The build flow is manual and brittle.
|
||||
- The setup depends on alpha-stage or pinned upstream tooling.
|
||||
- The local header patch is a red flag for maintainability.
|
||||
- The wrapper layer still carries noticeable manual boilerplate.
|
||||
- There is no obvious sign of tests, CI, or a long-term stability plan.
|
||||
|
||||
## Status
|
||||
|
||||
Current status: working prototype.
|
||||
|
||||
It appears far enough along to prove the interop path and demonstrate the tooling choices. It does not appear far enough along to support repeated
|
||||
reuse without more work on build integration, test coverage, and dependency stability.
|
||||
|
||||
In reviewer terms: promising experiment, useful reference, not ready to trust as infrastructure.
|
||||
|
||||
## Ecosystem Maturity
|
||||
|
||||
Rust/Haskell interop is uneven.
|
||||
|
||||
The low-level foundation is mature enough. Haskell has had a solid FFI story for years, and Rust is comfortable exporting or importing a C ABI.
|
||||
If the boundary is narrow and C-like, the approach is viable.
|
||||
|
||||
The weak part is the tooling layer. Header generation on the Rust side is serviceable. Binding generation on the Haskell side is improving, but it
|
||||
still looks early. The Garnet repo reflects that gap exactly: the ABI path works, but the workflow still needs custom glue and hand-written cleanup.
|
||||
|
||||
Reviewer verdict: mature enough for disciplined teams, not mature enough to feel easy.
|
||||
|
||||
## Calling Direction
|
||||
|
||||
### Calling Rust From Haskell
|
||||
|
||||
This is the easier direction.
|
||||
|
||||
Rust can expose a conventional C ABI, and Haskell can consume it through its normal FFI mechanisms. That keeps the ownership model and runtime story
|
||||
relatively simple, at least compared with the reverse direction.
|
||||
|
||||
This is the path Garnet takes, and it is the right first choice.
|
||||
|
||||
### Calling Haskell From Rust
|
||||
|
||||
This is the harder direction.
|
||||
|
||||
Once Rust starts calling into Haskell, the GHC runtime becomes part of the design. That raises the complexity around runtime initialization,
|
||||
threading, callbacks, shutdown, and operational correctness. It is possible, but it is a sharper tool and a worse default.
|
||||
|
||||
Reviewer verdict: call Rust from Haskell when possible; only call Haskell from Rust when there is a strong reason.
|
||||
|
||||
## Toolchain Recommendation
|
||||
|
||||
Current best default:
|
||||
|
||||
- keep the ABI small and C-shaped
|
||||
- use Rust `extern "C"` plus `repr(C)` at the boundary
|
||||
- use `cbindgen` to emit headers
|
||||
- keep Haskell bindings thin
|
||||
- write the final Haskell API by hand
|
||||
|
||||
That is not glamorous, but it is the most credible path today.
|
||||
|
||||
For teams that want the lowest risk, hand-written Haskell FFI bindings are still easier to trust than a large generated surface. For teams exploring
|
||||
automation, `hs-bindgen` is interesting but still reads as early-stage technology.
|
||||
|
||||
## Practical Read On Garnet
|
||||
|
||||
Garnet is valuable because it shows both sides of the story.
|
||||
|
||||
It shows that the basic interop path works. It also shows that the surrounding tooling is not yet smooth enough to disappear into the background.
|
||||
That makes it a good experiment and a fair warning.
|
||||
77
haskell/notes/_template.md
Normal file
77
haskell/notes/_template.md
Normal file
@ -0,0 +1,77 @@
|
||||
# <Project> Findings
|
||||
|
||||
Date: YYYY-MM-DD
|
||||
Path inspected: `<path>`
|
||||
|
||||
## Summary
|
||||
|
||||
`<path>` is a <one-line description>.
|
||||
|
||||
The repo is trying to prove or build <main idea>.
|
||||
|
||||
Verdict in one sentence: <works as X, does not yet read as Y>.
|
||||
|
||||
## What It Contains
|
||||
|
||||
- `<path/to/file-or-dir>` - <why it matters>
|
||||
- `<path/to/file-or-dir>` - <why it matters>
|
||||
- `<path/to/file-or-dir>` - <why it matters>
|
||||
- `<path/to/file-or-dir>` - <why it matters>
|
||||
|
||||
## Review
|
||||
|
||||
State the main architectural idea plainly.
|
||||
|
||||
Say what the repo gets right.
|
||||
|
||||
Say what still looks early, brittle, overcomplicated, missing, or high-risk.
|
||||
|
||||
Call out the main constraint directly: <build glue / unstable deps / missing tests / wrapper burden / runtime complexity / unclear ownership / etc.>
|
||||
|
||||
Keep this section short and judgmental in the useful sense. Write like a reviewer, not a tour guide.
|
||||
|
||||
## Pros
|
||||
|
||||
- <clear strength>
|
||||
- <clear strength>
|
||||
- <clear strength>
|
||||
- <clear strength>
|
||||
|
||||
## Cons
|
||||
|
||||
- <clear weakness>
|
||||
- <clear weakness>
|
||||
- <clear weakness>
|
||||
- <clear weakness>
|
||||
|
||||
## Status
|
||||
|
||||
Current status: <working prototype / partial implementation / mature subsystem / etc.>
|
||||
|
||||
State what is already proven.
|
||||
|
||||
State what would still need work before repeated reuse or production use.
|
||||
|
||||
End with a short reviewer verdict: <promising experiment / solid foundation / not ready to trust / etc.>
|
||||
|
||||
## Optional Sections
|
||||
|
||||
Add only if they help:
|
||||
|
||||
- `## Ecosystem Maturity`
|
||||
- `## Calling Direction`
|
||||
- `## Toolchain Recommendation`
|
||||
- `## Practical Read On <Project>`
|
||||
- `## Risks`
|
||||
- `## Next Problems`
|
||||
|
||||
## Writing Rules
|
||||
|
||||
- Use Title Case for headings.
|
||||
- Keep the tone direct and critical.
|
||||
- Prefer short paragraphs over long walkthroughs.
|
||||
- Do not write like an assistant explaining itself.
|
||||
- Avoid filler such as "it appears" unless the point is genuinely uncertain.
|
||||
- Prefer verdicts over summaries when the evidence is already clear.
|
||||
- If something is fragile, say it is fragile.
|
||||
- If something is promising but early, say that plainly.
|
||||
10
pyproject.toml
Normal file
10
pyproject.toml
Normal file
@ -0,0 +1,10 @@
|
||||
[project]
|
||||
name = "integrations"
|
||||
version = "0.1.0"
|
||||
description = "Python environment for the integrations project"
|
||||
|
||||
requires-python = ">=3.10,<4.0"
|
||||
dependencies = [
|
||||
"maturin[zig] (>=1.8.3,<2.0.0)",
|
||||
"numpy (>=2.2.6,<3.0.0)",
|
||||
]
|
||||
3
rust-toolchain.toml
Normal file
3
rust-toolchain.toml
Normal file
@ -0,0 +1,3 @@
|
||||
[toolchain]
|
||||
channel = "1.83.0"
|
||||
components = ["rustfmt", "clippy", "rust-analyzer"]
|
||||
34
rust/cli.rs
Normal file
34
rust/cli.rs
Normal file
@ -0,0 +1,34 @@
|
||||
use std::ffi::OsString;
|
||||
use tracing::error;
|
||||
|
||||
pub fn run(args: impl IntoIterator<Item = OsString>) -> Result<(), i32> {
|
||||
let _args: Vec<OsString> = args.into_iter().collect();
|
||||
// Your implementation here
|
||||
// Expecting at least 2 arguments
|
||||
if _args.len() < 2 {
|
||||
error!("Expecting at least 2 arguments");
|
||||
return Err(1);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Unit tests
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::ffi::OsString;
|
||||
|
||||
#[test]
|
||||
fn test_run_with_valid_args() {
|
||||
let args = vec![OsString::from("arg1"), OsString::from("arg2")];
|
||||
let result = run(args);
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_run_with_invalid_args() {
|
||||
let args = vec![OsString::from("invalid_arg")];
|
||||
let result = run(args);
|
||||
assert!(result.is_err());
|
||||
}
|
||||
}
|
||||
2
rust/lib.rs
Normal file
2
rust/lib.rs
Normal file
@ -0,0 +1,2 @@
|
||||
pub mod cli;
|
||||
pub mod logging;
|
||||
17
rust/logging.rs
Normal file
17
rust/logging.rs
Normal file
@ -0,0 +1,17 @@
|
||||
use ctor::ctor;
|
||||
use tracing::Level;
|
||||
use tracing_subscriber;
|
||||
|
||||
#[ctor]
|
||||
fn set_debug_level() {
|
||||
// If DEBUG_PROJ is not set or set to false, disable logging. Otherwise, enable logging
|
||||
if std::env::var("DEBUG_PROJ").map_or(true, |v| v == "0" || v == "false" || v.is_empty()) {
|
||||
// Disable logging
|
||||
} else {
|
||||
tracing_subscriber::fmt()
|
||||
.with_max_level(Level::DEBUG)
|
||||
.init();
|
||||
}
|
||||
|
||||
//println!("DEBUG_PROJ: {:?}", std::env::var("DEBUG_PROJ"));
|
||||
}
|
||||
7
rust/main.rs
Normal file
7
rust/main.rs
Normal file
@ -0,0 +1,7 @@
|
||||
use template_rust_project::cli::run;
|
||||
|
||||
fn main() {
|
||||
if let Err(code) = run(std::env::args_os()) {
|
||||
std::process::exit(code);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user