Add more #[must_use]
attributes (#1828)
This commit is contained in:
parent
28bd007f72
commit
32352f4bd1
27 changed files with 29 additions and 5 deletions
|
@ -12,6 +12,7 @@ use std::pin::Pin;
|
|||
|
||||
/// An authentication future
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct Authenticate<'r, C: Connection> {
|
||||
pub(super) router: Result<&'r Router<C>>,
|
||||
pub(super) token: Jwt,
|
||||
|
|
|
@ -11,6 +11,7 @@ use std::pin::Pin;
|
|||
|
||||
/// A beginning of a transaction
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct Begin<C: Connection> {
|
||||
pub(super) client: Surreal<C>,
|
||||
}
|
||||
|
@ -34,6 +35,7 @@ where
|
|||
|
||||
/// An ongoing transaction
|
||||
#[derive(Debug)]
|
||||
#[must_use = "transactions must be committed or cancelled to complete them"]
|
||||
pub struct Transaction<C: Connection> {
|
||||
client: Surreal<C>,
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ use std::pin::Pin;
|
|||
|
||||
/// A transaction cancellation future
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct Cancel<C: Connection> {
|
||||
pub(crate) client: Surreal<C>,
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ use std::pin::Pin;
|
|||
|
||||
/// A transaction commit future
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct Commit<C: Connection> {
|
||||
pub(crate) client: Surreal<C>,
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ use std::pin::Pin;
|
|||
///
|
||||
/// Content inserts or replaces the contents of a record entirely
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct Content<'r, C: Connection, D, R> {
|
||||
pub(super) router: Result<&'r Router<C>>,
|
||||
pub(super) method: Method,
|
||||
|
|
|
@ -14,6 +14,7 @@ use std::pin::Pin;
|
|||
|
||||
/// A record create future
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct Create<'r, C: Connection, R> {
|
||||
pub(super) router: Result<&'r Router<C>>,
|
||||
pub(super) resource: Result<Resource>,
|
||||
|
|
|
@ -14,6 +14,7 @@ use std::pin::Pin;
|
|||
|
||||
/// A record delete future
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct Delete<'r, C: Connection, R> {
|
||||
pub(super) router: Result<&'r Router<C>>,
|
||||
pub(super) resource: Result<Resource>,
|
||||
|
|
|
@ -12,6 +12,7 @@ use std::pin::Pin;
|
|||
|
||||
/// A database export future
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct Export<'r, C: Connection> {
|
||||
pub(super) router: Result<&'r Router<C>>,
|
||||
pub(super) file: PathBuf,
|
||||
|
|
|
@ -9,6 +9,7 @@ use std::pin::Pin;
|
|||
|
||||
/// A health check future
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct Health<'r, C: Connection> {
|
||||
pub(super) router: Result<&'r Router<C>>,
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ use std::pin::Pin;
|
|||
|
||||
/// An database import future
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct Import<'r, C: Connection> {
|
||||
pub(super) router: Result<&'r Router<C>>,
|
||||
pub(super) file: PathBuf,
|
||||
|
|
|
@ -11,6 +11,7 @@ use std::pin::Pin;
|
|||
|
||||
/// A session invalidate future
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct Invalidate<'r, C: Connection> {
|
||||
pub(super) router: Result<&'r Router<C>>,
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ use std::pin::Pin;
|
|||
|
||||
/// A live query kill future
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct Kill<'r, C: Connection> {
|
||||
pub(super) router: Result<&'r Router<C>>,
|
||||
pub(super) query_id: Uuid,
|
||||
|
|
|
@ -12,6 +12,7 @@ use std::pin::Pin;
|
|||
|
||||
/// A live query future
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct Live<'r, C: Connection> {
|
||||
pub(super) router: Result<&'r Router<C>>,
|
||||
pub(super) table_name: String,
|
||||
|
|
|
@ -16,6 +16,7 @@ use std::pin::Pin;
|
|||
|
||||
/// A merge future
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct Merge<'r, C: Connection, D, R> {
|
||||
pub(super) router: Result<&'r Router<C>>,
|
||||
pub(super) resource: Result<Resource>,
|
||||
|
|
|
@ -18,6 +18,7 @@ use std::result::Result as StdResult;
|
|||
|
||||
/// A patch future
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct Patch<'r, C: Connection, R> {
|
||||
pub(super) router: Result<&'r Router<C>>,
|
||||
pub(super) resource: Result<Resource>,
|
||||
|
|
|
@ -25,6 +25,7 @@ use std::pin::Pin;
|
|||
|
||||
/// A query future
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct Query<'r, C: Connection> {
|
||||
pub(super) router: Result<&'r Router<C>>,
|
||||
pub(super) query: Vec<Result<Vec<Statement>>>,
|
||||
|
|
|
@ -14,6 +14,7 @@ use std::pin::Pin;
|
|||
|
||||
/// A select future
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct Select<'r, C: Connection, R> {
|
||||
pub(super) router: Result<&'r Router<C>>,
|
||||
pub(super) resource: Result<Resource>,
|
||||
|
|
|
@ -10,6 +10,7 @@ use std::pin::Pin;
|
|||
|
||||
/// A set future
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct Set<'r, C: Connection> {
|
||||
pub(super) router: Result<&'r Router<C>>,
|
||||
pub(super) key: String,
|
||||
|
|
|
@ -14,6 +14,7 @@ use std::pin::Pin;
|
|||
|
||||
/// A signin future
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct Signin<'r, C: Connection, R> {
|
||||
pub(super) router: Result<&'r Router<C>>,
|
||||
pub(super) credentials: Result<Value>,
|
||||
|
|
|
@ -14,6 +14,7 @@ use std::pin::Pin;
|
|||
|
||||
/// A signup future
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct Signup<'r, C: Connection, R> {
|
||||
pub(super) router: Result<&'r Router<C>>,
|
||||
pub(super) credentials: Result<Value>,
|
||||
|
|
|
@ -9,6 +9,7 @@ use std::pin::Pin;
|
|||
|
||||
/// An unset future
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct Unset<'r, C: Connection> {
|
||||
pub(super) router: Result<&'r Router<C>>,
|
||||
pub(super) key: String,
|
||||
|
|
|
@ -19,6 +19,7 @@ use std::pin::Pin;
|
|||
|
||||
/// An update future
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct Update<'r, C: Connection, R> {
|
||||
pub(super) router: Result<&'r Router<C>>,
|
||||
pub(super) resource: Result<Resource>,
|
||||
|
|
|
@ -9,6 +9,7 @@ use std::future::IntoFuture;
|
|||
use crate::sql::Value;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct UseDb<'r, C: Connection> {
|
||||
pub(super) router: Result<&'r Router<C>>,
|
||||
pub(super) db: String,
|
||||
|
|
|
@ -9,6 +9,7 @@ use std::pin::Pin;
|
|||
|
||||
/// Stores the namespace to use
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct UseNs<'r, C: Connection> {
|
||||
pub(super) router: Result<&'r Router<C>>,
|
||||
pub(super) ns: String,
|
||||
|
@ -16,6 +17,7 @@ pub struct UseNs<'r, C: Connection> {
|
|||
|
||||
/// A use NS and DB future
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct UseNsDb<'r, C: Connection> {
|
||||
pub(super) router: Result<&'r Router<C>>,
|
||||
pub(super) ns: String,
|
||||
|
|
|
@ -10,6 +10,7 @@ use std::pin::Pin;
|
|||
|
||||
/// A version future
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct Version<'r, C: Connection> {
|
||||
pub(super) router: Result<&'r Router<C>>,
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ pub trait Connection: conn::Connection {}
|
|||
|
||||
/// The future returned when creating a new SurrealDB instance
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct Connect<'r, C: Connection, Response> {
|
||||
router: Option<&'r OnceCell<Arc<Router<C>>>>,
|
||||
address: Result<Endpoint>,
|
||||
|
@ -76,7 +77,6 @@ where
|
|||
/// # Ok(())
|
||||
/// # }
|
||||
/// ```
|
||||
#[must_use]
|
||||
pub const fn with_capacity(mut self, capacity: usize) -> Self {
|
||||
self.capacity = capacity;
|
||||
self
|
||||
|
|
|
@ -59,6 +59,7 @@ enum InnerOp<'a, T> {
|
|||
///
|
||||
/// [JSON Patch]: https://jsonpatch.com/
|
||||
#[derive(Debug)]
|
||||
#[must_use]
|
||||
pub struct PatchOp(pub(crate) Result<Value, crate::err::Error>);
|
||||
|
||||
impl PatchOp {
|
||||
|
@ -75,7 +76,6 @@ impl PatchOp {
|
|||
/// PatchOp::add("/biscuits/1", json!({ "name": "Ginger Nut" }))
|
||||
/// # ;
|
||||
/// ```
|
||||
#[must_use]
|
||||
pub fn add<T>(path: &str, value: T) -> Self
|
||||
where
|
||||
T: Serialize,
|
||||
|
@ -104,7 +104,6 @@ impl PatchOp {
|
|||
/// PatchOp::remove("/biscuits/0")
|
||||
/// # ;
|
||||
/// ```
|
||||
#[must_use]
|
||||
pub fn remove(path: &str) -> Self {
|
||||
Self(to_value(UnitOp::Remove {
|
||||
path,
|
||||
|
@ -122,7 +121,6 @@ impl PatchOp {
|
|||
/// PatchOp::replace("/biscuits/0/name", "Chocolate Digestive")
|
||||
/// # ;
|
||||
/// ```
|
||||
#[must_use]
|
||||
pub fn replace<T>(path: &str, value: T) -> Self
|
||||
where
|
||||
T: Serialize,
|
||||
|
@ -134,7 +132,6 @@ impl PatchOp {
|
|||
}
|
||||
|
||||
/// Changes a value
|
||||
#[must_use]
|
||||
pub fn change(path: &str, diff: Diff) -> Self {
|
||||
Self(to_value(UnitOp::Change {
|
||||
path,
|
||||
|
|
Loading…
Reference in a new issue