mirror of https://github.com/tikv/client-rust.git
doc: add section titles
Signed-off-by: ekexium <ekexium@gmail.com>
This commit is contained in:
parent
a42723766e
commit
635775f197
|
@ -38,6 +38,7 @@ impl Config {
|
|||
/// It's important to **include more than one PD endpoint** (include all, if possible!)
|
||||
/// This helps avoid having a *single point of failure*.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust
|
||||
/// # use tikv_client::Config;
|
||||
/// let config = Config::new(vec!["192.168.0.100:2379", "192.168.0.101:2379"]);
|
||||
|
@ -58,6 +59,7 @@ impl Config {
|
|||
/// By default, TiKV connections do not utilize transport layer security. Enable it by setting
|
||||
/// these values.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust
|
||||
/// # use tikv_client::Config;
|
||||
/// let config = Config::new(vec!["192.168.0.100:2379", "192.168.0.101:2379"]).with_security(
|
||||
|
|
|
@ -30,6 +30,7 @@ use tikv_client_proto::kvrpcpb;
|
|||
/// `impl Into<Key>`. You can implement `Into<BoundRange>` for your own types by using `try_from`.
|
||||
///
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust
|
||||
/// # use std::ops::{Range, RangeInclusive, RangeTo, RangeToInclusive, RangeFrom, RangeFull, Bound};
|
||||
/// # use std::convert::TryInto;
|
||||
|
@ -83,6 +84,7 @@ impl BoundRange {
|
|||
///
|
||||
/// The **end** of a scan is exclusive, unless appended with an '\0', then it is inclusive.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust
|
||||
/// use tikv_client::{BoundRange, Key, ToOwnedRange};
|
||||
/// // Exclusive
|
||||
|
|
|
@ -20,6 +20,7 @@ const _PROPTEST_KEY_MAX: usize = 1024 * 2; // 2 KB
|
|||
///
|
||||
/// This type wraps around an owned value, so it should be treated it like `String` or `Vec<u8>`.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust
|
||||
/// use tikv_client::Key;
|
||||
///
|
||||
|
@ -43,6 +44,7 @@ const _PROPTEST_KEY_MAX: usize = 1024 * 2; // 2 KB
|
|||
/// isn't able to determine the correct type. Notably in the `assert_eq!()` and `==` cases. In
|
||||
/// these cases using the fully-qualified-syntax is useful:
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust
|
||||
/// use tikv_client::Key;
|
||||
///
|
||||
|
|
|
@ -8,6 +8,7 @@ use tikv_client_proto::kvrpcpb;
|
|||
|
||||
/// A key/value pair.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust
|
||||
/// # use tikv_client::{Key, Value, KvPair};
|
||||
/// let key = "key".to_owned();
|
||||
|
|
|
@ -12,6 +12,7 @@ const _PROPTEST_VALUE_MAX: usize = 1024 * 16; // 16 KB
|
|||
///
|
||||
/// This type wraps around an owned value, so it should be treated it like `String` or `Vec<u8>`.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust
|
||||
/// use tikv_client::Value;
|
||||
///
|
||||
|
@ -35,6 +36,7 @@ const _PROPTEST_VALUE_MAX: usize = 1024 * 16; // 16 KB
|
|||
/// isn't able to determine the correct type. Notably in the `assert_eq!()` and `==` cases. In
|
||||
/// these cases using the fully-qualified-syntax is useful:
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust
|
||||
/// use tikv_client::Value;
|
||||
///
|
||||
|
|
|
@ -27,6 +27,7 @@ pub struct Client {
|
|||
impl Client {
|
||||
/// Create a raw [`Client`](Client).
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust,no_run
|
||||
/// # use tikv_client::{Config, RawClient};
|
||||
/// # use futures::prelude::*;
|
||||
|
@ -52,6 +53,7 @@ impl Client {
|
|||
///
|
||||
/// For normal users of the raw API, you don't need to use other column families.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust,no_run
|
||||
/// # use tikv_client::{Config, RawClient, ColumnFamily};
|
||||
/// # use futures::prelude::*;
|
||||
|
@ -79,6 +81,7 @@ impl Client {
|
|||
///
|
||||
/// By default, `key_only` is set to false.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust,no_run
|
||||
/// # use tikv_client::{Config, RawClient, ToOwnedRange};
|
||||
/// # use futures::prelude::*;
|
||||
|
@ -102,6 +105,7 @@ impl Client {
|
|||
///
|
||||
/// Retuning `Ok(None)` indicates the key does not exist in TiKV.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust,no_run
|
||||
/// # use tikv_client::{Value, Config, RawClient};
|
||||
/// # use futures::prelude::*;
|
||||
|
@ -125,6 +129,7 @@ impl Client {
|
|||
///
|
||||
/// Non-existent entries will not appear in the result. The order of the keys is not retained in the result.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust,no_run
|
||||
/// # use tikv_client::{KvPair, Config, RawClient};
|
||||
/// # use futures::prelude::*;
|
||||
|
@ -148,6 +153,7 @@ impl Client {
|
|||
///
|
||||
/// Once resolved this request will result in the setting of the value associated with the given key.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust,no_run
|
||||
/// # use tikv_client::{Key, Value, Config, RawClient};
|
||||
/// # use futures::prelude::*;
|
||||
|
@ -169,6 +175,7 @@ impl Client {
|
|||
///
|
||||
/// Once resolved this request will result in the setting of the values associated with the given keys.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust,no_run
|
||||
/// # use tikv_client::{Error, Result, KvPair, Key, Value, Config, RawClient, ToOwnedRange};
|
||||
/// # use futures::prelude::*;
|
||||
|
@ -196,6 +203,7 @@ impl Client {
|
|||
///
|
||||
/// It does not return an error if the key does not exist in TiKV.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust,no_run
|
||||
/// # use tikv_client::{Key, Config, RawClient};
|
||||
/// # use futures::prelude::*;
|
||||
|
@ -218,6 +226,7 @@ impl Client {
|
|||
///
|
||||
/// It does not return an error if some of the keys do not exist and will delete the others.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust,no_run
|
||||
/// # use tikv_client::{Config, RawClient};
|
||||
/// # use futures::prelude::*;
|
||||
|
@ -238,6 +247,7 @@ impl Client {
|
|||
///
|
||||
/// Once resolved this request will result in the deletion of all keys lying in the given range.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust,no_run
|
||||
/// # use tikv_client::{Key, Config, RawClient, ToOwnedRange};
|
||||
/// # use futures::prelude::*;
|
||||
|
@ -262,6 +272,7 @@ impl Client {
|
|||
/// only the first `limit` pairs are returned, ordered by the key.
|
||||
///
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust,no_run
|
||||
/// # use tikv_client::{KvPair, Config, RawClient, ToOwnedRange};
|
||||
/// # use futures::prelude::*;
|
||||
|
@ -296,6 +307,7 @@ impl Client {
|
|||
/// As a result, you may get **more than** `each_limit` key-value pairs for each range.
|
||||
/// But you should not miss any entries.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust,no_run
|
||||
/// # use tikv_client::{Key, Config, RawClient, ToOwnedRange};
|
||||
/// # use futures::prelude::*;
|
||||
|
|
|
@ -30,6 +30,7 @@ mod requests;
|
|||
///
|
||||
/// The best (and only) way to create a [`ColumnFamily`](ColumnFamily) is via the `From` implementation:
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust
|
||||
/// # use tikv_client::ColumnFamily;
|
||||
/// # use std::convert::TryFrom;
|
||||
|
|
|
@ -43,6 +43,7 @@ pub struct Client {
|
|||
impl Client {
|
||||
/// Creates a transactional [`Client`](Client).
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust,no_run
|
||||
/// use tikv_client::{Config, TransactionClient};
|
||||
/// use futures::prelude::*;
|
||||
|
@ -76,6 +77,7 @@ impl Client {
|
|||
///
|
||||
/// For details, check our [SIG-transaction](https://github.com/tikv/sig-transaction/tree/master/doc/tikv#optimistic-and-pessimistic-transactions).
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust,no_run
|
||||
/// use tikv_client::{Config, TransactionClient};
|
||||
/// use futures::prelude::*;
|
||||
|
@ -97,6 +99,7 @@ impl Client {
|
|||
/// Write operations will lock the data until commit, thus commit requests should not suffer from write conflict.
|
||||
/// For details, check our [SIG-transaction](https://github.com/tikv/sig-transaction/tree/master/doc/tikv#optimistic-and-pessimistic-transactions).
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust,no_run
|
||||
/// use tikv_client::{Config, TransactionClient};
|
||||
/// use futures::prelude::*;
|
||||
|
@ -120,6 +123,7 @@ impl Client {
|
|||
|
||||
/// Retrieves the current [`Timestamp`](Timestamp).
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust,no_run
|
||||
/// use tikv_client::{Config, TransactionClient};
|
||||
/// use futures::prelude::*;
|
||||
|
|
|
@ -32,6 +32,7 @@ use tikv_client_proto::{kvrpcpb, pdpb::Timestamp};
|
|||
/// provides materials explaining designs and implementations of multiple features in TiKV transactions.
|
||||
///
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust,no_run
|
||||
/// use tikv_client::{Config, TransactionClient};
|
||||
/// use futures::prelude::*;
|
||||
|
@ -104,6 +105,7 @@ impl Transaction {
|
|||
///
|
||||
/// It can only be used in pessimistic mode.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust,no_run
|
||||
/// # use tikv_client::{Value, Config, TransactionClient};
|
||||
/// # use futures::prelude::*;
|
||||
|
@ -139,6 +141,7 @@ impl Transaction {
|
|||
///
|
||||
/// Non-existent entries will not appear in the result. The order of the keys is not retained in the result.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust,no_run
|
||||
/// # use tikv_client::{Key, Value, Config, TransactionClient};
|
||||
/// # use futures::prelude::*;
|
||||
|
@ -177,6 +180,7 @@ impl Transaction {
|
|||
///
|
||||
/// Non-existent entries will not appear in the result. The order of the keys is not retained in the result.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust,no_run
|
||||
/// # use tikv_client::{Key, Value, Config, TransactionClient};
|
||||
/// # use futures::prelude::*;
|
||||
|
@ -216,6 +220,7 @@ impl Transaction {
|
|||
/// If the number of eligible key-value pairs are greater than `limit`,
|
||||
/// only the first `limit` pairs are returned, ordered by the key.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust,no_run
|
||||
/// # use tikv_client::{Key, KvPair, Value, Config, TransactionClient};
|
||||
/// # use futures::prelude::*;
|
||||
|
@ -254,12 +259,13 @@ impl Transaction {
|
|||
/// Create a 'scan_reverse' request.
|
||||
///
|
||||
/// Similar to [`scan`](Transaction::scan), but in the reverse direction.
|
||||
fn scan_reverse(&self, _range: impl RangeBounds<Key>) -> BoxStream<Result<KvPair>> {
|
||||
pub(crate) fn scan_reverse(&self, _range: impl RangeBounds<Key>) -> BoxStream<Result<KvPair>> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
/// Sets the value associated with the given key.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust,no_run
|
||||
/// # use tikv_client::{Key, Value, Config, TransactionClient};
|
||||
/// # use futures::prelude::*;
|
||||
|
@ -286,6 +292,7 @@ impl Transaction {
|
|||
///
|
||||
/// Deleting a non-existent key will not result in an error.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust,no_run
|
||||
/// # use tikv_client::{Key, Config, TransactionClient};
|
||||
/// # use futures::prelude::*;
|
||||
|
@ -316,6 +323,7 @@ impl Transaction {
|
|||
///
|
||||
/// In pessimistic mode, please use [`get_for_update`](Transaction::get_for_update) instead.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust,no_run
|
||||
/// # use tikv_client::{Config, TransactionClient};
|
||||
/// # use futures::prelude::*;
|
||||
|
@ -336,6 +344,7 @@ impl Transaction {
|
|||
|
||||
/// Commits the actions of the transaction.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust,no_run
|
||||
/// # use tikv_client::{Config, TransactionClient};
|
||||
/// # use futures::prelude::*;
|
||||
|
|
Loading…
Reference in New Issue