Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,45 @@
# libchat
Supporting library for Logos-chat

Supporting library for Logos-chat.

## Prerequisites

Install Rust via [rustup](https://rust-lang.org/tools/install/):

## Quick Start

### Using Cargo

```bash
# Build
cargo build

# Run tests
cargo test

# Run examples
cargo run --example double_ratchet_basic
```

### Using Just

Install [just](https://github.com/casey/just) to manage complex tasks.

On MacOS, you can install it via Homebrew:

```bash
brew install just
```

After that, run:

```bash
# Build
just build

# Run tests
just test

# Run all examples
just run-examples
```
3 changes: 1 addition & 2 deletions double-ratchets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ Run examples,
```bash
cargo run --example double_ratchet_basic

cargo run --example storage_demo --features storage
cargo run --example storage_demo --features sqlcipher
cargo run --example storage_demo
```

Run Nim FFI example,
Expand Down
13 changes: 13 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# The first receipt is the default task, run with `just`
build:
cargo build

test:
cargo test

# Run all examples
run-examples:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually valuable? How often does someone want to run all the examples at once?

This seems like it is trying to perform the same job as integration tests.

Copy link
Contributor Author

@kaichaosun kaichaosun Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I run this command for the PRs I made after this change, before I was running such demos one by one, and easily forgot one and introduce bug.

In my previous experience, I see a lot of failing demos or even no demos in some of logos messaging repos, I want to avoid such scenarios happened in libchat.

Copy link
Collaborator

@jazzz jazzz Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

However if the goal is to ensure that demo code isn't broken, then it should be ensured via CI and tests.

Add tests that ensure specific behaviour you are looking for and then add cargo test --examples to ensure they meet the expected results.

Simply executing the examples doesn't ensure they are operating correctly.

Copy link
Contributor Author

@kaichaosun kaichaosun Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, CI will be added later.
Tests is not clearly show the workflow like demos, that's why most rust libraries contains examples directory, which is good in may ways.
Running examples ensures it successful, without such helper, it will be hard to check all the examples easily.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also updated the readme to indicate just is not mandatory, and using Cargo as an option to get started.

cargo run --example double_ratchet_basic
cargo run --example serialization_demo
cargo run --example storage_demo
cargo run --example out_of_order_demo
Comment on lines +9 to +13
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these examples are hidden behind feature flags. If we want people to be able to run examples easily then it would make sense to remove the storage feature as it doesn't seem that optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The storage feature has been removed in this PR: #30, please review this PR too when you see fit.