open-engineering-hello 0.1.0

A minimal example crate from Open Engineering
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented1 out of 1 items with examples
  • Size
  • Source code size: 6.9 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 22.1 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 4s Average build duration of successful builds.
  • all releases: 4s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • wvanheemstra github:open-engineering-crates:crates

Open Engineering Hello

A minimal Rust crate published by Open Engineering.

Account Setup

Go to your crates.io account settings -> API Tokens and create a new token.

For this first test, give it a descriptive name such as:

open-engineering-crates-publishing

Then, in your terminal, run:

cargo login

Cargo will prompt:

please paste the token found on https://crates.io/me below

Paste the crates.io token. Cargo stores the credentials locally, so do not put tokens in Cargo.toml, .env, or Git.

For CI/CD later, don't use your locally stored token. Instead use a crates.io token through your CI secret store, exposed as:

CARGO_REGISTRY_TOKEN

For this first manual publication, though, cargo login is exactly what you want.

Pre-requisites

On Linux or a GitHub Codespace, run:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Choose the default installation (1).

Then load Cargo into your current shell:

source "$HOME/.cargo/env"

Verify:

rustc --version
cargo --version
rustup --version

You should now have all three:

rustc ...
cargo ...
rustup ...

Tip: Add Rust installation to the repository's Dev Container configuration so every fresh Codespace gets cargo automatically rather than requiring this manual setup.

Usage

Add the crate:

cargo add open-engineering-hello

Note: If you get the error: cannot add `open-engineering-hello` as a dependency to itself, Cargo correctly refsuses to add a package as its own dependency. For the crate repository, you do not need that command. Just test the library directly:

cargo test

The command cargo add open-engineering-hello belongs in a different project that consumes your published crate.

For example, after publishing, you could test installation like this:

cd /tmp
cargo new hello-consumer
cd hello-consumer

cargo add open-engineering-hello

Then replace src/main.rs with:

fn main() {
  println!("{}", open_engineering_hello::hello());
}

And run:

cargo run

Expected output:

Hello, Open Engineering!

Open Engineering

This crate is part of the Open Engineering ecosystem.

https://open-engineering.io

Before publishing

From the repository root:

cargo fmt --check
cargo test
cargo clippy --all-targets --all-features -- -D warnings
cargo package

Then inspect what Cargo intends to upload:

cargo package --list

And perform the important dry run:

cargo publish --dry-run

Once everything looks right:

cargo publish

Then assign the GitHub team you created (i.e. crates):

cargo owner \
  --add github:open-engineering-crates:crates \
  open-engineering-hello

That produces a rather nice first end-to-end proof:

GitHub
open-engineering-crates/source
         |
         | cargo publish
         V
crates.io
open-engineering-hello
         |
         | ownership
         V
github:open-engineering-crates:crates
         |
         | documentation
         V
docs.rs
open-engineering-hello