Skip to content

Commit d2751d3

Browse files
authored
docs(readme): no_run instead of ignore (#324)
1 parent 48cca8a commit d2751d3

File tree

1 file changed

+115
-44
lines changed

1 file changed

+115
-44
lines changed

README.md

Lines changed: 115 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ clickhouse = { version = "0.14.0", features = ["test-util"] }
7373

7474
</summary>
7575

76-
```rust,ignore
76+
```rust,no_run
7777
use clickhouse::Client;
7878
7979
let client = Client::default()
@@ -93,7 +93,7 @@ let client = Client::default()
9393

9494
</summary>
9595

96-
```rust,ignore
96+
```rust,no_run
9797
use serde::Deserialize;
9898
use clickhouse::Row;
9999
@@ -103,13 +103,19 @@ struct MyRow<'a> {
103103
name: &'a str,
104104
}
105105
106-
let mut cursor = client
107-
.query("SELECT ?fields FROM some WHERE no BETWEEN ? AND ?")
108-
.bind(500)
109-
.bind(504)
110-
.fetch::<MyRow<'_>>()?;
106+
async fn example(client: clickhouse::Client) -> clickhouse::error::Result<()> {
107+
let mut cursor = client
108+
.query("SELECT ?fields FROM some WHERE no BETWEEN ? AND ?")
109+
.bind(500)
110+
.bind(504)
111+
.fetch::<MyRow<'_>>()?;
111112
112-
while let Some(row) = cursor.next().await? { .. }
113+
while let Some(row) = cursor.next().await? {
114+
println!("no: {}, name: {}", row.no, row.name);
115+
}
116+
117+
Ok(())
118+
}
113119
```
114120

115121
* Placeholder `?fields` is replaced with `no, name` (fields of `Row`).
@@ -127,7 +133,7 @@ Note that cursors can return an error even after producing some rows. To avoid t
127133

128134
</summary>
129135

130-
```rust,ignore
136+
```rust,no_run
131137
use serde::Serialize;
132138
use clickhouse::Row;
133139
@@ -137,10 +143,13 @@ struct MyRow {
137143
name: String,
138144
}
139145
140-
let mut insert = client.insert::<MyRow>("some").await?;
141-
insert.write(&MyRow { no: 0, name: "foo".into() }).await?;
142-
insert.write(&MyRow { no: 1, name: "bar".into() }).await?;
143-
insert.end().await?;
146+
async fn example(client: clickhouse::Client) -> clickhouse::error::Result<()> {
147+
let mut insert = client.insert::<MyRow>("some").await?;
148+
insert.write(&MyRow { no: 0, name: "foo".into() }).await?;
149+
insert.write(&MyRow { no: 1, name: "bar".into() }).await?;
150+
insert.end().await?;
151+
Ok(())
152+
}
144153
```
145154

146155
* If `end()` isn't called, the `INSERT` is aborted.
@@ -157,21 +166,35 @@ insert.end().await?;
157166

158167
Requires the `inserter` feature.
159168

160-
```rust,ignore
161-
let mut inserter = client.inserter::<MyRow>("some")?
162-
.with_timeouts(Some(Duration::from_secs(5)), Some(Duration::from_secs(20)))
163-
.with_max_bytes(50_000_000)
164-
.with_max_rows(750_000)
165-
.with_period(Some(Duration::from_secs(15)));
166-
167-
inserter.write(&MyRow { no: 0, name: "foo".into() }).await?;
168-
inserter.write(&MyRow { no: 1, name: "bar".into() }).await?;
169-
let stats = inserter.commit().await?;
170-
if stats.rows > 0 {
171-
println!(
172-
"{} bytes, {} rows, {} transactions have been inserted",
173-
stats.bytes, stats.rows, stats.transactions,
174-
);
169+
```rust,no_run
170+
use serde::Serialize;
171+
use clickhouse::Row;
172+
use clickhouse::inserter::Inserter;
173+
use std::time::Duration;
174+
175+
#[derive(Row, Serialize)]
176+
struct MyRow {
177+
no: u32,
178+
name: String,
179+
}
180+
181+
async fn example(client: clickhouse::Client) -> clickhouse::error::Result<()> {
182+
let mut inserter = client.inserter::<MyRow>("some")
183+
.with_timeouts(Some(Duration::from_secs(5)), Some(Duration::from_secs(20)))
184+
.with_max_bytes(50_000_000)
185+
.with_max_rows(750_000)
186+
.with_period(Some(Duration::from_secs(15)));
187+
188+
inserter.write(&MyRow { no: 0, name: "foo".into() }).await?;
189+
inserter.write(&MyRow { no: 1, name: "bar".into() }).await?;
190+
let stats = inserter.commit().await?;
191+
if stats.rows > 0 {
192+
println!(
193+
"{} bytes, {} rows, {} transactions have been inserted",
194+
stats.bytes, stats.rows, stats.transactions,
195+
);
196+
}
197+
Ok(())
175198
}
176199
```
177200

@@ -195,8 +218,11 @@ inserter.end().await?;
195218

196219
</summary>
197220

198-
```rust,ignore
199-
client.query("DROP TABLE IF EXISTS some").execute().await?;
221+
```rust,no_run
222+
async fn example(client: clickhouse::Client) -> clickhouse::error::Result<()> {
223+
client.query("DROP TABLE IF EXISTS some").execute().await?;
224+
Ok(())
225+
}
200226
```
201227

202228
</details>
@@ -242,7 +268,10 @@ How to choose between all these features? Here are some considerations:
242268
<details>
243269
<summary>Example</summary>
244270

245-
```rust,ignore
271+
```rust,no_run
272+
use serde::{Serialize, Deserialize};
273+
use clickhouse::Row;
274+
246275
#[derive(Row, Debug, Serialize, Deserialize)]
247276
struct MyRow<'a> {
248277
str: &'a str,
@@ -258,7 +287,9 @@ How to choose between all these features? Here are some considerations:
258287
<details>
259288
<summary>Example</summary>
260289
261-
```rust,ignore
290+
```rust,no_run
291+
use clickhouse::Row;
292+
use serde::{Serialize, Deserialize};
262293
#[derive(Row, Debug, Serialize, Deserialize)]
263294
struct MyRow {
264295
fixed_str: [u8; 16], // FixedString(16)
@@ -270,7 +301,9 @@ How to choose between all these features? Here are some considerations:
270301
<details>
271302
<summary>Example</summary>
272303
273-
```rust,ignore
304+
```rust,no_run
305+
use clickhouse::Row;
306+
use serde::{Serialize, Deserialize};
274307
use serde_repr::{Deserialize_repr, Serialize_repr};
275308
276309
#[derive(Row, Serialize, Deserialize)]
@@ -292,7 +325,10 @@ How to choose between all these features? Here are some considerations:
292325
<details>
293326
<summary>Example</summary>
294327
295-
```rust,ignore
328+
```rust,no_run
329+
use serde::{Serialize, Deserialize};
330+
use clickhouse::Row;
331+
296332
#[derive(Row, Serialize, Deserialize)]
297333
struct MyRow {
298334
#[serde(with = "clickhouse::serde::uuid")]
@@ -305,7 +341,10 @@ How to choose between all these features? Here are some considerations:
305341
<details>
306342
<summary>Example</summary>
307343
308-
```rust,ignore
344+
```rust,no_run
345+
use serde::{Serialize, Deserialize};
346+
use clickhouse::Row;
347+
309348
#[derive(Row, Serialize, Deserialize)]
310349
struct MyRow {
311350
#[serde(with = "clickhouse::serde::ipv4")]
@@ -319,7 +358,12 @@ How to choose between all these features? Here are some considerations:
319358
<details>
320359
<summary>Example</summary>
321360
322-
```rust,ignore
361+
```rust,no_run
362+
use serde::{Serialize, Deserialize};
363+
use clickhouse::Row;
364+
use time::Date;
365+
use chrono::NaiveDate;
366+
323367
#[derive(Row, Serialize, Deserialize)]
324368
struct MyRow {
325369
days: u16,
@@ -338,7 +382,12 @@ How to choose between all these features? Here are some considerations:
338382
<details>
339383
<summary>Example</summary>
340384
341-
```rust,ignore
385+
```rust,no_run
386+
use serde::{Serialize, Deserialize};
387+
use clickhouse::Row;
388+
use time::Date;
389+
use chrono::NaiveDate;
390+
342391
#[derive(Row, Serialize, Deserialize)]
343392
struct MyRow {
344393
days: i32,
@@ -358,7 +407,11 @@ How to choose between all these features? Here are some considerations:
358407
<details>
359408
<summary>Example</summary>
360409
361-
```rust,ignore
410+
```rust,no_run
411+
use serde::{Serialize, Deserialize};
412+
use clickhouse::Row;
413+
use time::OffsetDateTime;
414+
use chrono::{DateTime, Utc};
362415
#[derive(Row, Serialize, Deserialize)]
363416
struct MyRow {
364417
ts: u32,
@@ -376,7 +429,12 @@ How to choose between all these features? Here are some considerations:
376429
<details>
377430
<summary>Example</summary>
378431
379-
```rust,ignore
432+
```rust,no_run
433+
use serde::{Serialize, Deserialize};
434+
use clickhouse::Row;
435+
use time::OffsetDateTime;
436+
use chrono::{DateTime, Utc};
437+
380438
#[derive(Row, Serialize, Deserialize)]
381439
struct MyRow {
382440
ts: i64, // elapsed s/us/ms/ns depending on `DateTime64(X)`
@@ -408,7 +466,9 @@ How to choose between all these features? Here are some considerations:
408466
<details>
409467
<summary>Example</summary>
410468
411-
```rust,ignore
469+
```rust,no_run
470+
use serde::{Serialize, Deserialize};
471+
use clickhouse::Row;
412472
#[derive(Row, Serialize, Deserialize)]
413473
struct MyRow {
414474
#[serde(with = "clickhouse::serde::chrono::time64::secs")]
@@ -442,7 +502,10 @@ How to choose between all these features? Here are some considerations:
442502
<details>
443503
<summary>Example</summary>
444504
445-
```rust,ignore
505+
```rust,no_run
506+
use clickhouse::Row;
507+
use serde::{Serialize, Deserialize};
508+
use std::net::Ipv4Addr;
446509
#[derive(Row, Serialize, Deserialize)]
447510
struct MyRow {
448511
#[serde(with = "clickhouse::serde::ipv4::option")]
@@ -454,8 +517,10 @@ How to choose between all these features? Here are some considerations:
454517
<details>
455518
<summary>Example</summary>
456519
457-
```rust,ignore
520+
```rust,no_run
458521
// CREATE TABLE test(items Nested(name String, count UInt32))
522+
use clickhouse::Row;
523+
use serde::{Serialize, Deserialize};
459524
#[derive(Row, Serialize, Deserialize)]
460525
struct MyRow {
461526
#[serde(rename = "items.name")]
@@ -470,7 +535,10 @@ How to choose between all these features? Here are some considerations:
470535
<details>
471536
<summary>Example</summary>
472537
473-
```rust,ignore
538+
```rust,no_run
539+
use clickhouse::Row;
540+
use serde::{Serialize, Deserialize};
541+
474542
type Point = (f64, f64);
475543
type Ring = Vec<Point>;
476544
type Polygon = Vec<Ring>;
@@ -493,7 +561,10 @@ How to choose between all these features? Here are some considerations:
493561
<details>
494562
<summary>Example</summary>
495563
496-
```rust,ignore
564+
```rust,no_run
565+
use clickhouse::Row;
566+
use serde::{Serialize, Deserialize};
567+
use time::Date;
497568
#[derive(Serialize, Deserialize)]
498569
enum MyRowVariant {
499570
Array(Vec<i16>),

0 commit comments

Comments
 (0)