MCPcopy Create free account
hub / github.com/chatmail/core / query_row_optional

Method query_row_optional

src/sql.rs:528–547  ·  view source on GitHub ↗

Execute a query which is expected to return zero or one row.

(
        &self,
        sql: &str,
        params: impl rusqlite::Params + Send,
        f: F,
    )

Source from the content-addressed store, hash-verified

526
527 /// Execute a query which is expected to return zero or one row.
528 pub async fn query_row_optional<T, F>(
529 &self,
530 sql: &str,
531 params: impl rusqlite::Params + Send,
532 f: F,
533 ) -> Result<Option<T>>
534 where
535 F: Send + FnOnce(&rusqlite::Row) -> rusqlite::Result<T>,
536 T: Send + 'static,
537 {
538 let query_only = true;
539 self.call(query_only, move |conn| {
540 match conn.query_row(sql.as_ref(), params, f) {
541 Ok(res) => Ok(Some(res)),
542 Err(rusqlite::Error::QueryReturnedNoRows) => Ok(None),
543 Err(err) => Err(err.into()),
544 }
545 })
546 .await
547 }
548
549 /// Executes a query which is expected to return one row and one
550 /// column. If the query does not return any rows, returns `Ok(None)`.

Callers 15

download_msgFunction · 0.80
import_public_keyFunction · 0.80
get_by_id_optionalMethod · 0.80
public_keyMethod · 0.80
send_msg_to_smtpFunction · 0.80
send_mdnFunction · 0.80
query_get_valueMethod · 0.80
from_field_to_contact_idFunction · 0.80
parent_queryMethod · 0.80

Calls 3

callMethod · 0.80
query_rowMethod · 0.80
as_refMethod · 0.45

Tested by 2

pop_sent_msg_exMethod · 0.64
first_row_in_smtp_queueFunction · 0.64