examples: Move all examples to the root folder

This commit is contained in:
Kévin Commaille 2022-03-18 16:37:16 +01:00 committed by Kévin Commaille
parent 5cc3656c27
commit 2621dced1b
12 changed files with 80 additions and 23 deletions

View File

@ -173,20 +173,4 @@ ruma-identity-service-api = { version = "0.4.0", path = "../ruma-identity-servic
ruma-push-gateway-api = { version = "0.4.0", path = "../ruma-push-gateway-api", optional = true } ruma-push-gateway-api = { version = "0.4.0", path = "../ruma-push-gateway-api", optional = true }
[dev-dependencies] [dev-dependencies]
anyhow = "1.0.37"
isahc = "1.3.1"
serde = { version = "1.0.118", features = ["derive"] } serde = { version = "1.0.118", features = ["derive"] }
tokio = { version = "1.0.1", features = ["macros", "rt"] }
tokio-stream = { version = "0.1.1", default-features = false }
[[example]]
name = "hello_world"
required-features = ["client-api-c", "client-ext-client-api", "client-hyper-native-tls", "rand"]
[[example]]
name = "hello_isahc"
required-features = ["client-api-c", "client-ext-client-api", "client-isahc", "rand"]
[[example]]
name = "message_log"
required-features = ["client-api-c", "client-ext-client-api", "client-hyper-native-tls"]

View File

@ -2,5 +2,3 @@
These are example projects showcasing how to use the various crates in this repository. You can use These are example projects showcasing how to use the various crates in this repository. You can use
these as a base for starting your own project. these as a base for starting your own project.
Other examples can be found in the [examples directory of the `ruma` crate](../crates/ruma/examples).

View File

@ -0,0 +1,13 @@
[package]
name = "hello_isahc"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
ruma = { version = "0.5.0", path = "../../crates/ruma", features = ["client-api-c", "client-ext-client-api", "client-isahc", "rand"] }
anyhow = "1.0.37"
isahc = "1.3.1"
tokio = { version = "1.0.1", features = ["macros", "rt"] }

View File

@ -0,0 +1,13 @@
Same as the [hello_world](../hello_world) example, but using the
[isahc](https://crates.io/crates/isahc) HTTP client (a Rust wrapper around libcurl).
# Usage
You will need to use an existing account on a homeserver that allows login with
a password.
In this folder, you can run it with this command:
```shell
cargo run <homeserver_url> <username> <password> <room>
```

View File

@ -1,6 +1,3 @@
//! Same as the hello_world example, but using the isahc http client (a Rust wrapper around
//! libcurl).
use std::{convert::TryFrom, env, process::exit}; use std::{convert::TryFrom, env, process::exit};
use ruma::{ use ruma::{

View File

@ -0,0 +1,12 @@
[package]
name = "hello_world"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
ruma = { version = "0.5.0", path = "../../crates/ruma", features = ["client-api-c", "client-ext-client-api", "client-hyper-native-tls", "rand"] }
anyhow = "1.0.37"
tokio = { version = "1.0.1", features = ["macros", "rt"] }

View File

@ -0,0 +1,13 @@
A simple example to demonstrate `ruma-client` functionality. Sends "Hello
World!" to the given room.
# Usage
You will need to use an existing account on a homeserver that allows login with
a password.
In this folder, you can run it with this command:
```shell
cargo run <homeserver_url> <username> <password> <room>
```

View File

@ -2,10 +2,10 @@ use std::{convert::TryFrom, env, process::exit};
use ruma::{ use ruma::{
api::client::{alias::get_alias, membership::join_room_by_id, message::send_message_event}, api::client::{alias::get_alias, membership::join_room_by_id, message::send_message_event},
common::TransactionId,
events::room::message::RoomMessageEventContent, events::room::message::RoomMessageEventContent,
RoomAliasId, RoomAliasId,
}; };
use ruma_common::TransactionId;
type HttpClient = ruma::client::http_client::HyperNativeTls; type HttpClient = ruma::client::http_client::HyperNativeTls;

View File

@ -6,7 +6,7 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
ruma = { version = "0.5.0", path = "../../crates/ruma", features = ["client", "client-api-c", "client-ext-client-api", "client-hyper-native-tls", "events", "rand"] } ruma = { version = "0.5.0", path = "../../crates/ruma", features = ["client-api-c", "client-ext-client-api", "client-hyper-native-tls", "rand"] }
# For building locally: use the git dependencies below. # For building locally: use the git dependencies below.
# Browse the source at this revision here: https://github.com/ruma/ruma/tree/f161c8117c706fc52089999e1f406cf34276ec9d # Browse the source at this revision here: https://github.com/ruma/ruma/tree/f161c8117c706fc52089999e1f406cf34276ec9d
# ruma = { git = "https://github.com/ruma/ruma", rev = "f161c8117c706fc52089999e1f406cf34276ec9d", features = ["client-api-c", "client", "client-hyper-native-tls", "events"] } # ruma = { git = "https://github.com/ruma/ruma", rev = "f161c8117c706fc52089999e1f406cf34276ec9d", features = ["client-api-c", "client", "client-hyper-native-tls", "events"] }

View File

@ -0,0 +1,14 @@
[package]
name = "message_log"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
ruma = { version = "0.5.0", path = "../../crates/ruma", features = ["client-api-c", "client-ext-client-api", "client-hyper-native-tls"] }
anyhow = "1.0.37"
assign = "1.1.1"
tokio = { version = "1.0.1", features = ["macros", "rt"] }
tokio-stream = { version = "0.1.1", default-features = false }

View File

@ -0,0 +1,13 @@
A simple example to demonstrate `ruma-client` functionality. Prints all the
received text messages to stdout.
# Usage
You will need to use an existing account on a homeserver that allows login with
a password.
In this folder, you can run it with this command:
```shell
cargo run <homeserver_url> <username> <password>
```