Skip to main content

QuerySet

Struct QuerySet 

Source
pub struct QuerySet<T>
where T: Model,
{ /* private fields */ }
Available on crate feature database and non-WebAssembly only.
Expand description

Represents a query set.

Implementations§

Source§

impl<T> QuerySet<T>
where T: Model,

Source

pub fn new() -> QuerySet<T>

Creates a new instance.

Source

pub fn with_manager(manager: Arc<Manager<T>>) -> QuerySet<T>

Sets the manager and returns self for chaining.

Source

pub fn filter(self, filter: Filter) -> QuerySet<T>

Performs the filter operation.

Source

pub fn from_subquery<M, F>(builder: F, alias: &str) -> QuerySet<T>
where M: Model + 'static, F: FnOnce(QuerySet<M>) -> QuerySet<M>,

Create a QuerySet from a subquery (FROM clause subquery / derived table)

This method creates a new QuerySet that uses a subquery as its data source instead of a regular table. The subquery becomes a derived table in the FROM clause.

§Type Parameters
  • M - The model type for the subquery
  • F - A closure that builds the subquery
§Parameters
  • builder - A closure that receives a fresh QuerySet<M> and returns a configured QuerySet
  • alias - The alias for the derived table (required for FROM subqueries)
§Examples
// Query from a derived table showing author book counts
let results = QuerySet::<Book>::from_subquery(
    |subq: QuerySet<Book>| {
        subq.values(&["author_id"])
            .annotate(Annotation::new("book_count", AnnotationValue::Aggregate(Aggregate::count_all())))
    },
    "book_stats"
)
.filter(Filter::new("book_count", FilterOperator::Gt, FilterValue::Int(1)))
.to_sql();
// Generates: SELECT * FROM (SELECT author_id, COUNT(*) AS book_count FROM books GROUP BY author_id) AS book_stats WHERE book_count > 1
Source

pub fn inner_join<R>(self, left_field: &str, right_field: &str) -> QuerySet<T>
where R: Model,

Add an INNER JOIN to the query

Performs an INNER JOIN between the current model (T) and another model (R). Only rows with matching values in both tables are included in the result.

§Type Parameters
  • R - The model type to join with (must implement Model trait)
§Parameters
  • left_field - The field name from the left table (current model T)
  • right_field - The field name from the right table (model R)
§Examples
// Join User and Post on user.id = post.user_id
let sql = User::objects()
    .all()
    .inner_join::<Post>("id", "user_id")
    .to_sql();
Source

pub fn left_join<R>(self, left_field: &str, right_field: &str) -> QuerySet<T>
where R: Model,

Add a LEFT OUTER JOIN to the query

Performs a LEFT OUTER JOIN between the current model (T) and another model (R). All rows from the left table are included, with matching rows from the right table or NULL values if no match is found.

§Examples
// Left join User and Post
let sql = User::objects()
    .all()
    .left_join::<Post>("id", "user_id")
    .to_sql();
Source

pub fn right_join<R>(self, left_field: &str, right_field: &str) -> QuerySet<T>
where R: Model,

Add a RIGHT OUTER JOIN to the query

Performs a RIGHT OUTER JOIN between the current model (T) and another model (R). All rows from the right table are included, with matching rows from the left table or NULL values if no match is found.

§Examples
// Right join User and Post
let sql = User::objects()
    .all()
    .right_join::<Post>("id", "user_id")
    .to_sql();
Source

pub fn cross_join<R>(self) -> QuerySet<T>
where R: Model,

Add a CROSS JOIN to the query

Performs a CROSS JOIN between the current model (T) and another model (R). Produces the Cartesian product of both tables (all possible combinations). No ON condition is needed for CROSS JOIN.

§Examples
// Cross join User and Category
let sql = User::objects()
    .all()
    .cross_join::<Category>()
    .to_sql();
Source

pub fn from_as(self, alias: &str) -> QuerySet<T>

Set an alias for the base table (FROM clause)

This is useful for self-joins where you need to reference the same table multiple times.

§Parameters
  • alias - The alias name for the base table
§Examples
// Self-join: find user pairs
let sql = User::objects()
    .all()
    .from_as("u1")
    .inner_join_as::<User, _>("u1", "u2", |left, right| left.id.field_lt(right.id))
    .to_sql();
Source

pub fn inner_join_on<R>(self, condition: &str) -> QuerySet<T>
where R: Model,

Add an INNER JOIN with custom condition

Performs an INNER JOIN with a custom ON condition expression. Use this when you need complex join conditions beyond simple equality.

§Type Parameters
  • R - The model type to join with (must implement Model trait)
§Parameters
  • condition - Custom SQL condition for the JOIN (e.g., “users.id = posts.user_id AND posts.status = ‘published’”)
§Examples
// Join with complex condition
let sql = User::objects()
    .all()
    .inner_join_on::<Post>("users.id = posts.user_id AND posts.title LIKE 'First%'")
    .to_sql();
Source

pub fn left_join_on<R>(self, condition: &str) -> QuerySet<T>
where R: Model,

Add a LEFT OUTER JOIN with custom condition

Similar to inner_join_on() but performs a LEFT OUTER JOIN.

§Type Parameters
  • R - The model type to join with (must implement Model trait)
§Parameters
  • condition - Custom SQL condition for the JOIN
§Examples
let sql = User::objects()
    .all()
    .left_join_on::<Post>("users.id = posts.user_id AND posts.published = true")
    .to_sql();
Source

pub fn right_join_on<R>(self, condition: &str) -> QuerySet<T>
where R: Model,

Add a RIGHT OUTER JOIN with custom condition

Similar to inner_join_on() but performs a RIGHT OUTER JOIN.

§Type Parameters
  • R - The model type to join with (must implement Model trait)
§Parameters
  • condition - Custom SQL condition for the JOIN
§Examples
let sql = User::objects()
    .all()
    .right_join_on::<Post>("users.id = posts.user_id AND users.active = true")
    .to_sql();
Source

pub fn inner_join_as<R, F>( self, left_alias: &str, right_alias: &str, condition_fn: F, ) -> QuerySet<T>
where R: Model, F: FnOnce(<T as Model>::Fields, <R as Model>::Fields) -> FieldComparison,

Add an INNER JOIN with table alias

Performs an INNER JOIN with an alias for the target table. Useful for self-joins or when you need to reference the same table multiple times.

§Type Parameters
  • R - The model type to join with (must implement Model trait)
  • F - Closure that builds the JOIN ON condition
§Parameters
  • alias - Alias name for the target table
  • condition_fn - Closure that receives a JoinOnBuilder and returns it with the condition set
§Examples
// Self-join: find user pairs where user1.id < user2.id
let sql = User::objects()
    .all()
    .inner_join_as::<User, _>("u1", "u2", |u1, u2| u1.id.field_lt(u2.id))
    .to_sql();
§Breaking Change

The signature of this method has been changed from string-based JOIN conditions to type-safe field comparisons.

Source

pub fn left_join_as<R, F>( self, left_alias: &str, right_alias: &str, condition_fn: F, ) -> QuerySet<T>
where R: Model, F: FnOnce(<T as Model>::Fields, <R as Model>::Fields) -> FieldComparison,

Add a LEFT OUTER JOIN with table alias

Similar to inner_join_as() but performs a LEFT OUTER JOIN.

§Type Parameters
  • R - The model type to join with (must implement Model trait)
  • F - Closure that builds the JOIN ON condition
§Parameters
  • alias - Alias name for the target table
  • condition_fn - Closure that receives a JoinOnBuilder and returns it with the condition set
§Examples
// Self-join with LEFT JOIN: find employees and their managers
let sql = User::objects()
    .all()
    .left_join_as::<User, _>("u1", "u2", |u1, u2| u2.id.field_eq(u1.manager_id))
    .to_sql();
§Breaking Change

This method signature has been changed from string-based JOIN conditions to type-safe field comparisons.

Source

pub fn right_join_as<R, F>( self, left_alias: &str, right_alias: &str, condition_fn: F, ) -> QuerySet<T>
where R: Model, F: FnOnce(<T as Model>::Fields, <R as Model>::Fields) -> FieldComparison,

Add a RIGHT OUTER JOIN with table alias

Similar to inner_join_as() but performs a RIGHT OUTER JOIN.

§Type Parameters
  • R - The model type to join with (must implement Model trait)
  • F - Closure that builds the JOIN ON condition
§Parameters
  • alias - Alias name for the target table
  • condition_fn - Closure that receives a JoinOnBuilder and returns it with the condition set
§Examples
// RIGHT JOIN: find all departments even if no users belong to them
let sql = User::objects()
    .all()
    .right_join_as::<User, _>("u1", "u2", |u1, u2| u2.id.field_eq(u1.department_id))
    .to_sql();
§Breaking Change

This method signature has been changed from string-based JOIN conditions to type-safe field comparisons.

Source

pub fn group_by<F>(self, selector_fn: F) -> QuerySet<T>
where F: FnOnce(<T as Model>::Fields) -> GroupByFields,

Add GROUP BY clause to the query

Groups rows that have the same values in specified columns into summary rows. Typically used with aggregate functions (COUNT, MAX, MIN, SUM, AVG).

§Type Parameters
  • F - Closure that builds the GROUP BY field list
§Parameters
  • builder_fn - Closure that receives a GroupByBuilder and returns it with fields set
§Examples
// Group by single field
let sql1 = Book::objects()
    .all()
    .group_by(|fields| GroupByFields::new().add(&fields.author_id))
    .to_sql();

// Group by multiple fields (chain .add())
let sql2 = Sale::objects()
    .all()
    .group_by(|fields| GroupByFields::new().add(&fields.region).add(&fields.product_category))
    .to_sql();
§Breaking Change

This method signature has been changed from string-based field selection to type-safe field selectors.

Source

pub fn having_avg<FS, FE, NT>( self, field_selector: FS, expr_fn: FE, ) -> QuerySet<T>
where FS: FnOnce(&<T as Model>::Fields) -> &Field<T, NT>, NT: NumericType, FE: FnOnce(AggregateExpr) -> ComparisonExpr,

Add HAVING clause for AVG aggregate

Filters grouped rows based on the average value of a field.

§Type Parameters
  • F - Closure that selects the field
§Parameters
  • field_fn - Closure that receives a HavingFieldSelector and returns it with the field set
  • operator - Comparison operator (Eq, Ne, Gt, Gte, Lt, Lte)
  • value - Value to compare against
§Examples
// Find authors with average book price > 1500
let sql = Author::objects()
    .all()
    .group_by(|fields| GroupByFields::new().add(&fields.author_id))
    .having_avg(|fields| &fields.price, |avg| avg.gt(1500.0))
    .to_sql();
§Breaking Change

This method signature has been changed to use type-safe field selectors and aggregate expressions.

Source

pub fn having_count<F>(self, expr_fn: F) -> QuerySet<T>

Add HAVING clause for COUNT aggregate

Filters grouped rows based on the count of rows in each group.

§Type Parameters
  • F - Closure that selects the field
§Parameters
  • field_fn - Closure that receives a HavingFieldSelector and returns it with the field set
  • operator - Comparison operator (Eq, Ne, Gt, Gte, Lt, Lte)
  • value - Value to compare against
§Examples
// Find authors with more than 5 books
let sql = Author::objects()
    .all()
    .group_by(|fields| GroupByFields::new().add(&fields.author_id))
    .having_count(|count| count.gt(5))
    .to_sql();
§Breaking Change

This method signature has been changed to use type-safe aggregate expressions.

Source

pub fn having_sum<FS, FE, NT>( self, field_selector: FS, expr_fn: FE, ) -> QuerySet<T>
where FS: FnOnce(&<T as Model>::Fields) -> &Field<T, NT>, NT: NumericType, FE: FnOnce(AggregateExpr) -> ComparisonExpr,

Add HAVING clause for SUM aggregate

Filters grouped rows based on the sum of values in a field.

§Type Parameters
  • F - Closure that selects the field
§Parameters
  • field_fn - Closure that receives a HavingFieldSelector and returns it with the field set
  • operator - Comparison operator (Eq, Ne, Gt, Gte, Lt, Lte)
  • value - Value to compare against
§Examples
// Find categories with total sales > 10000
let sql = Product::objects()
    .all()
    .group_by(|fields| GroupByFields::new().add(&fields.category))
    .having_sum(|fields| &fields.sales_amount, |sum| sum.gt(10000.0))
    .to_sql();
§Breaking Change

This method signature has been changed to use type-safe field selectors.

Source

pub fn having_min<FS, FE, NT>( self, field_selector: FS, expr_fn: FE, ) -> QuerySet<T>
where FS: FnOnce(&<T as Model>::Fields) -> &Field<T, NT>, NT: NumericType, FE: FnOnce(AggregateExpr) -> ComparisonExpr,

Add HAVING clause for MIN aggregate

Filters grouped rows based on the minimum value in a field.

§Breaking Change

This method signature has been changed to use type-safe field selectors.

§Type Parameters
  • FS - Field selector closure that returns a reference to a numeric field
  • FE - Expression closure that builds the comparison expression
§Parameters
  • field_selector - Closure that selects the field from the model
  • expr_fn - Closure that builds the comparison expression using method chaining
§Examples
// Find authors where minimum book price > 1000
let sql = Author::objects()
    .all()
    .group_by(|fields| GroupByFields::new().add(&fields.author_id))
    .having_min(|fields| &fields.price, |min| min.gt(1000.0))
    .to_sql();
Source

pub fn having_max<FS, FE, NT>( self, field_selector: FS, expr_fn: FE, ) -> QuerySet<T>
where FS: FnOnce(&<T as Model>::Fields) -> &Field<T, NT>, NT: NumericType, FE: FnOnce(AggregateExpr) -> ComparisonExpr,

Add HAVING clause for MAX aggregate

Filters grouped rows based on the maximum value in a field.

§Breaking Change

This method signature has been changed to use type-safe field selectors.

§Type Parameters
  • FS - Field selector closure that returns a reference to a numeric field
  • FE - Expression closure that builds the comparison expression
§Parameters
  • field_selector - Closure that selects the field from the model
  • expr_fn - Closure that builds the comparison expression using method chaining
§Examples
// Find authors where maximum book price < 5000
let sql = Author::objects()
    .all()
    .group_by(|fields| GroupByFields::new().add(&fields.author_id))
    .having_max(|fields| &fields.price, |max| max.lt(5000.0))
    .to_sql();
Source

pub fn filter_in_subquery<R, F>( self, field: &str, subquery_fn: F, ) -> QuerySet<T>
where R: Model, F: FnOnce(QuerySet<R>) -> QuerySet<R>,

Add WHERE IN (subquery) condition

Filters rows where the specified field’s value is in the result set of a subquery.

§Type Parameters
  • R - The model type used in the subquery (must implement Model trait)
  • F - Function that builds the subquery QuerySet
§Examples
// Find authors who have books priced over 1500
let authors = Author::objects()
    .filter_in_subquery("id", |subq: QuerySet<Book>| {
        subq.filter(Filter::new("price", FilterOperator::Gt, FilterValue::Int(1500)))
            .values(&["author_id"])
    })
    .all()
    .await?;
Source

pub fn filter_not_in_subquery<R, F>( self, field: &str, subquery_fn: F, ) -> QuerySet<T>
where R: Model, F: FnOnce(QuerySet<R>) -> QuerySet<R>,

Add WHERE NOT IN (subquery) condition

Filters rows where the specified field’s value is NOT in the result set of a subquery.

§Examples
// Find authors who have NO books priced over 1500
let authors = Author::objects()
    .filter_not_in_subquery("id", |subq: QuerySet<Book>| {
        subq.filter(Filter::new("price", FilterOperator::Gt, FilterValue::Int(1500)))
            .values(&["author_id"])
    })
    .all()
    .await?;
Source

pub fn filter_exists<R, F>(self, subquery_fn: F) -> QuerySet<T>
where R: Model, F: FnOnce(QuerySet<R>) -> QuerySet<R>,

Add WHERE EXISTS (subquery) condition

Filters rows where the subquery returns at least one row. Typically used with correlated subqueries.

§Examples
use reinhardt_db::orm::F;
// Find authors who have at least one book
let authors = Author::objects()
    .filter_exists(|subq: QuerySet<Book>| {
        subq.filter(Filter::new("author_id", FilterOperator::Eq, FilterValue::FieldRef(F::new("authors.id"))))
    })
    .all()
    .await?;
Source

pub fn filter_not_exists<R, F>(self, subquery_fn: F) -> QuerySet<T>
where R: Model, F: FnOnce(QuerySet<R>) -> QuerySet<R>,

Add WHERE NOT EXISTS (subquery) condition

Filters rows where the subquery returns no rows. Typically used with correlated subqueries.

§Examples
use reinhardt_db::orm::F;
// Find authors who have NO books
let authors = Author::objects()
    .filter_not_exists(|subq: QuerySet<Book>| {
        subq.filter(Filter::new("author_id", FilterOperator::Eq, FilterValue::FieldRef(F::new("authors.id"))))
    })
    .all()
    .await?;
Source

pub fn with_cte(self, cte: CTE) -> QuerySet<T>

Add a Common Table Expression (WITH clause) to the query

CTEs allow you to define named subqueries that can be referenced in the main query. This is useful for complex queries that need to reference the same subquery multiple times or for recursive queries.

§Examples
// Simple CTE
let high_earners = CTE::new("high_earners", "SELECT * FROM employees WHERE salary > 100000");
let results = Employee::objects()
    .with_cte(high_earners)
    .all()
    .await?;

// Recursive CTE for hierarchical data
let hierarchy = CTE::new(
    "org_hierarchy",
    "SELECT id, name, manager_id, 1 as level FROM employees WHERE manager_id IS NULL \
     UNION ALL \
     SELECT e.id, e.name, e.manager_id, h.level + 1 \
     FROM employees e JOIN org_hierarchy h ON e.manager_id = h.id"
).recursive();

let org = Employee::objects()
    .with_cte(hierarchy)
    .all()
    .await?;
Source

pub fn with_lateral_join(self, join: LateralJoin) -> QuerySet<T>

Add a LATERAL JOIN to the query

LATERAL JOINs allow correlated subqueries in the FROM clause, where the subquery can reference columns from preceding tables. This is useful for “top-N per group” queries and similar patterns.

Note: LATERAL JOIN is supported in PostgreSQL 9.3+, MySQL 8.0.14+, but NOT in SQLite.

§Examples
use reinhardt_db::orm::lateral_join::{LateralJoin, LateralJoinPatterns};

// Get top 3 orders per customer
let top_orders = LateralJoinPatterns::top_n_per_group(
    "recent_orders",
    "orders",
    "customer_id",
    "customers",
    "created_at DESC",
    3,
);

let results = Customer::objects()
    .all()
    .with_lateral_join(top_orders)
    .all()
    .await?;

// Get latest order per customer
let latest = LateralJoinPatterns::latest_per_parent(
    "latest_order",
    "orders",
    "customer_id",
    "customers",
    "created_at",
);

let customers_with_orders = Customer::objects()
    .all()
    .with_lateral_join(latest)
    .all()
    .await?;

Eagerly load related objects using JOIN queries

This method performs SQL JOINs to fetch related objects in a single query, reducing the number of database round-trips and preventing N+1 query problems.

§Performance

Best for one-to-one and many-to-one relationships where JOIN won’t create significant data duplication. For one-to-many and many-to-many relationships, consider using prefetch_related() instead.

§Examples
// Single query with JOINs instead of N+1 queries
let posts = Post::objects()
    .select_related(&["author", "category"])
    .all()
    .await?;

// Each post has author and category pre-loaded
for post in posts {
    println!("Author: {}", post.author.name); // No additional query
}

Generate SELECT query with JOIN clauses for select_related fields

Returns reinhardt-query SelectStatement with LEFT JOIN for each related field to enable eager loading.

§Examples
let queryset = Post::objects()
    .select_related(&["author", "category"])
    .filter(Filter::new("published", FilterOperator::Eq, FilterValue::Boolean(true)));

let stmt = queryset.select_related_query();
// Generates:
// SELECT posts.*, author.*, category.* FROM posts
//   LEFT JOIN users AS author ON posts.author_id = author.id
//   LEFT JOIN categories AS category ON posts.category_id = category.id
//   WHERE posts.published = $1

Eagerly load related objects using separate queries

This method performs separate SQL queries for related objects and joins them in memory, which is more efficient than JOINs for one-to-many and many-to-many relationships that would create significant data duplication.

§Performance

Best for one-to-many and many-to-many relationships where JOINs would create data duplication (e.g., a post with 100 comments would duplicate post data 100 times). Uses 1 + N queries where N is the number of prefetch_related fields.

§Examples
// 2 queries total instead of N+1 queries
let posts = Post::objects()
    .prefetch_related(&["comments", "tags"])
    .all()
    .await?;

// Each post has comments and tags pre-loaded
for post in posts {
    for comment in &post.comments {
        println!("Comment: {}", comment.text); // No additional query
    }
}

Generate SELECT queries for prefetch_related fields

Returns a vector of (field_name, SelectStatement) tuples, one for each prefetch field. Each query fetches related objects using IN clause with collected primary keys.

§Examples
let queryset = Post::objects()
    .prefetch_related(&["comments", "tags"]);

let main_results = queryset.all().await?; // Main query
let pk_values = vec![1, 2, 3]; // Collected from main results

let prefetch_queries = queryset.prefetch_related_queries(&pk_values);
// Returns SelectStatements for:
// 1. comments: SELECT * FROM comments WHERE post_id IN ($1, $2, $3)
// 2. tags: SELECT tags.* FROM tags
//          INNER JOIN post_tags ON tags.id = post_tags.tag_id
//          WHERE post_tags.post_id IN ($1, $2, $3)
Source

pub async fn all(&self) -> Result<Vec<T>, Error>

Execute the queryset and return all matching records

Fetches all records from the database that match the accumulated filters. If select_related fields are specified, performs JOIN queries for eager loading.

§Examples
// Fetch all users (Manager.all() returns QuerySet, then call .all().await)
let users = User::objects().all().all().await?;

// Fetch filtered users with eager loading
let active_users = User::objects()
    .filter(
        "is_active",
        FilterOperator::Eq,
        FilterValue::Boolean(true),
    )
    .select_related(&["profile"])
    .all()
    .await?;
§Errors

Returns an error if:

  • Database connection fails
  • SQL execution fails
  • Deserialization of results fails
Source

pub async fn first(&self) -> Result<Option<T>, Error>

Execute the queryset and return the first matching record

Returns None if no records match the query.

§Examples
// Fetch first active user
let user = User::objects()
    .filter(
        "is_active",
        FilterOperator::Eq,
        FilterValue::Boolean(true),
    )
    .first()
    .await?;

match user {
    Some(u) => println!("Found user: {}", u.username),
    None => println!("No active users found"),
}
Source

pub async fn get(&self) -> Result<T, Error>

Execute the queryset and return a single matching record

Returns an error if zero or multiple records are found.

§Examples
// Fetch user with specific email (must be unique)
let user = User::objects()
    .filter(
        "email",
        FilterOperator::Eq,
        FilterValue::String("alice@example.com".to_string()),
    )
    .get()
    .await?;
§Errors

Returns an error if:

  • No records match the query
  • Multiple records match the query
  • Database connection fails
Source

pub async fn all_with_db( &self, conn: &DatabaseConnection, ) -> Result<Vec<T>, Error>

Execute the queryset with an explicit database connection and return all records

§Examples
let users = User::objects()
    .all()
    .all_with_db(&db)
    .await?;
Source

pub async fn get_with_db(&self, conn: &DatabaseConnection) -> Result<T, Error>

Execute the queryset with an explicit database connection and return a single record

§Examples
let db = reinhardt_db::orm::manager::get_connection().await?;
let user = User::objects()
    .filter("id", reinhardt_db::orm::FilterOperator::Eq, reinhardt_db::orm::FilterValue::Integer(user_id))
    .get_with_db(&db)
    .await?;
Source

pub async fn first_with_db( &self, conn: &DatabaseConnection, ) -> Result<Option<T>, Error>

Execute the queryset with an explicit database connection and return the first record

§Examples
let db = reinhardt_db::orm::manager::get_connection().await?;
let user = User::objects()
    .filter("status", reinhardt_db::orm::FilterOperator::Eq, reinhardt_db::orm::FilterValue::String("active".to_string()))
    .first_with_db(&db)
    .await?;
Source

pub async fn count(&self) -> Result<usize, Error>

Execute the queryset and return the count of matching records

More efficient than calling all().await?.len() as it only executes COUNT query.

§Examples
// Count active users
let count = User::objects()
    .filter(
        "is_active",
        FilterOperator::Eq,
        FilterValue::Boolean(true),
    )
    .count()
    .await?;

println!("Active users: {}", count);
Source

pub async fn exists(&self) -> Result<bool, Error>

Check if any records match the queryset

More efficient than calling count().await? > 0 as it can short-circuit.

§Examples
// Check if any admin users exist
let has_admin = User::objects()
    .filter(
        "role",
        FilterOperator::Eq,
        FilterValue::String("admin".to_string()),
    )
    .exists()
    .await?;

if has_admin {
    println!("Admin users exist");
}
Source

pub async fn create(&self, object: T) -> Result<T, Error>
where T: Model + Clone,

Create a new object in the database

§Examples
let user = User {
    id: None,
    username: "alice".to_string(),
    email: "alice@example.com".to_string(),
};
let created = User::objects().create(&user).await?;
Source

pub fn update_query( &self, updates: &HashMap<String, UpdateValue>, ) -> UpdateStatement

Generate UPDATE statement using reinhardt-query

Source

pub fn update_sql( &self, updates: &HashMap<String, UpdateValue>, ) -> (String, Vec<String>)

Generate UPDATE SQL with WHERE clause and parameter binding

Returns SQL with placeholders ($1, $2, etc.) and the values to bind.

§Examples
use std::collections::HashMap;
let queryset = User::objects()
    .filter("id", FilterOperator::Eq, FilterValue::Integer(1));

let mut updates = HashMap::new();
updates.insert("name".to_string(), UpdateValue::String("Alice".to_string()));
updates.insert("email".to_string(), UpdateValue::String("alice@example.com".to_string()));
let (sql, params) = queryset.update_sql(&updates);
// sql: "UPDATE users SET name = $1, email = $2 WHERE id = $3"
// params: ["Alice", "alice@example.com", "1"]
Source

pub fn delete_query(&self) -> DeleteStatement

Generate DELETE SQL with WHERE clause and parameter binding

Returns SQL with placeholders ($1, $2, etc.) and the values to bind.

§Safety

This method will panic if no filters are set to prevent accidental deletion of all rows. Always use .filter() before calling this method.

§Examples
let queryset = User::objects()
    .filter("id", FilterOperator::Eq, FilterValue::Integer(1));

let (sql, params) = queryset.delete_sql();
// sql: "DELETE FROM users WHERE id = $1"
// params: ["1"]

Generate DELETE statement using reinhardt-query

Source

pub fn delete_sql(&self) -> (String, Vec<String>)

Deletes sql.

Source

pub async fn get_composite( &self, pk_values: &HashMap<String, PkValue>, ) -> Result<T, Error>
where T: Model + Clone,

Retrieve a single object by composite primary key

This method queries the database using all fields that compose the composite primary key. It validates that all required primary key fields are provided and returns the matching record.

§Examples
let mut pk_values = HashMap::new();
pk_values.insert("post_id".to_string(), PkValue::Int(1));
pk_values.insert("tag_id".to_string(), PkValue::Int(5));

let post_tag = PostTag::objects().get_composite(&pk_values).await?;
§Errors

Returns an error if:

  • The model doesn’t have a composite primary key
  • Required primary key fields are missing from the provided values
  • No matching record is found in the database
  • Multiple records match (should not happen with a valid composite PK)
Source

pub fn annotate(self, annotation: Annotation) -> QuerySet<T>

Add an annotation to the QuerySet

Annotations allow you to add calculated fields to query results using expressions, aggregations, or subqueries. The annotation will be added to the SELECT clause.

§Examples
use reinhardt_db::orm::annotation::{Annotation, AnnotationValue};
use reinhardt_db::orm::aggregation::Aggregate;

// Add aggregate annotation
let users = User::objects()
    .annotate(Annotation::new("total_orders",
        AnnotationValue::Aggregate(Aggregate::count(Some("orders")))))
    .all()
    .await?;
Source

pub fn annotate_subquery<M, F>(self, name: &str, builder: F) -> QuerySet<T>
where M: Model + 'static, F: FnOnce(QuerySet<M>) -> QuerySet<M>,

Add a subquery annotation to the QuerySet (SELECT clause subquery)

This method adds a scalar subquery to the SELECT clause, allowing you to include computed values from related tables without explicit JOINs.

§Type Parameters
  • M - The model type for the subquery
  • F - A closure that builds the subquery
§Parameters
  • name - The alias for the subquery result column
  • builder - A closure that receives a fresh QuerySet<M> and returns a configured QuerySet
§Examples
// Add book count for each author
let authors = Author::objects()
    .annotate_subquery::<Book, _>("book_count", |subq| {
        subq.filter(Filter::new(
            "author_id",
            FilterOperator::Eq,
            FilterValue::OuterRef(OuterRef::new("authors.id"))
        ))
        .values(&["COUNT(*)"])
    })
    .all()
    .await?;
// Generates: SELECT *, (SELECT COUNT(*) FROM books WHERE author_id = authors.id) AS book_count FROM authors
Source

pub fn aggregate(self, aggregate: Aggregate) -> QuerySet<T>

Perform an aggregation on the QuerySet

Aggregations allow you to calculate summary statistics (COUNT, SUM, AVG, MAX, MIN) for the queryset. The aggregation result will be added to the SELECT clause.

§Examples
use reinhardt_db::orm::aggregation::Aggregate;

// Count all users
let result = User::objects()
    .all()
    .aggregate(Aggregate::count_all().with_alias("total_users"))
    .all()
    .await?;

// Sum order amounts
let result = Order::objects()
    .all()
    .aggregate(Aggregate::sum("amount").with_alias("total_amount"))
    .all()
    .await?;
Source

pub fn to_sql(&self) -> String

Converts to sql.

Source

pub fn values(self, fields: &[&str]) -> QuerySet<T>

Select specific values from the QuerySet

Returns only the specified fields instead of all columns. Useful for optimizing queries when you don’t need all model fields.

§Examples
// Select only specific fields
let users = User::objects()
    .values(&["id", "username", "email"])
    .all()
    .await?;
// Generates: SELECT id, username, email FROM users

// Combine with filters
let active_user_names = User::objects()
    .filter("is_active", FilterOperator::Eq, FilterValue::Boolean(true))
    .values(&["username"])
    .all()
    .await?;
Source

pub fn values_list(self, fields: &[&str]) -> QuerySet<T>

Select specific values as a list

Alias for values() - returns tuple-like results with specified fields. In Django, this returns tuples instead of dictionaries, but in Rust the behavior is the same as values() due to type safety.

§Examples
// Same as values()
let user_data = User::objects()
    .values_list(&["id", "username"])
    .all()
    .await?;
Source

pub fn order_by(self, fields: &[&str]) -> QuerySet<T>

Order the QuerySet by specified fields

§Examples
// Ascending order
User::objects().order_by(&["name"]);

// Descending order (prefix with '-')
User::objects().order_by(&["-created_at"]);

// Multiple fields
User::objects().order_by(&["department", "-salary"]);
Source

pub fn distinct(self) -> QuerySet<T>

Return only distinct results

Source

pub fn limit(self, limit: usize) -> QuerySet<T>

Set LIMIT clause

Limits the number of records returned by the query. Corresponds to Django’s QuerySet slicing [:limit].

§Examples
let users = User::objects()
    .limit(10)
    .all()
    .await?;
Source

pub fn offset(self, offset: usize) -> QuerySet<T>

Set OFFSET clause

Skips the specified number of records before returning results. Corresponds to Django’s QuerySet slicing [offset:].

§Examples
let users = User::objects()
    .offset(20)
    .limit(10)
    .all()
    .await?;
Source

pub fn paginate(self, page: usize, page_size: usize) -> QuerySet<T>

Paginate results using page number and page size

Convenience method that calculates offset automatically. Corresponds to Django REST framework’s PageNumberPagination.

§Examples
// Page 3, 10 items per page (offset=20, limit=10)
let users = User::objects()
    .paginate(3, 10)
    .all()
    .await?;
Source

pub fn as_subquery(self) -> String

Convert QuerySet to a subquery

Returns the QuerySet as a SQL subquery wrapped in parentheses, suitable for use in IN clauses, EXISTS clauses, or as a derived table.

§Examples
// Use in IN clause
let active_user_ids = User::objects()
    .filter("is_active", FilterOperator::Eq, FilterValue::Bool(true))
    .values(&["id"])
    .as_subquery();
// Generates: (SELECT id FROM users WHERE is_active = $1)

// Use as derived table
let subquery = Post::objects()
    .filter("published", FilterOperator::Eq, FilterValue::Bool(true))
    .as_subquery();
// Generates: (SELECT * FROM posts WHERE published = $1)
Source

pub fn defer(self, fields: &[&str]) -> QuerySet<T>

Defer loading of specific fields

Marks specific fields for deferred loading (lazy loading). The specified fields will be excluded from the initial query.

§Examples
// Defer large text fields
let users = User::objects()
    .defer(&["bio", "profile_picture"])
    .all()
    .await?;
// Generates: SELECT id, username, email FROM users (excluding bio, profile_picture)
Source

pub fn only(self, fields: &[&str]) -> QuerySet<T>

Load only specific fields

Alias for values() - specifies which fields to load immediately. In Django, this is used for deferred loading optimization, but in Rust it behaves the same as values().

§Examples
// Load only specific fields
let users = User::objects()
    .only(&["id", "username"])
    .all()
    .await?;
// Generates: SELECT id, username FROM users

Filter by PostgreSQL full-text search

This method adds a filter for full-text search using PostgreSQL’s @@ operator. The query is converted using plainto_tsquery for simple word matching.

§Arguments
  • field - The tsvector field to search
  • query - The search query string
§Examples
// Search articles for "rust programming"
let articles = Article::objects()
    .full_text_search("search_vector", "rust programming")
    .all()
    .await?;
// Generates: WHERE search_vector @@ plainto_tsquery('english', 'rust programming')
Source

pub fn filter_array_overlap(self, field: &str, values: &[&str]) -> QuerySet<T>

Filter by PostgreSQL array overlap

Returns rows where the array field has at least one element in common with the given values.

§Arguments
  • field - The array field name
  • values - Values to check for overlap
§Examples
// Find posts with any of these tags
let posts = Post::objects()
    .filter_array_overlap("tags", &["rust", "programming"])
    .all()
    .await?;
// Generates: WHERE tags && ARRAY['rust', 'programming']
Source

pub fn filter_array_contains(self, field: &str, values: &[&str]) -> QuerySet<T>

Filter by PostgreSQL array containment

Returns rows where the array field contains all the given values.

§Arguments
  • field - The array field name
  • values - Values that must all be present in the array
§Examples
// Find posts that have both "rust" and "async" tags
let posts = Post::objects()
    .filter_array_contains("tags", &["rust", "async"])
    .all()
    .await?;
// Generates: WHERE tags @> ARRAY['rust', 'async']
Source

pub fn filter_jsonb_contains(self, field: &str, json: &str) -> QuerySet<T>

Filter by PostgreSQL JSONB containment

Returns rows where the JSONB field contains the given JSON object.

§Arguments
  • field - The JSONB field name
  • json - JSON string to check for containment
§Examples
// Find products with specific metadata
let products = Product::objects()
    .filter_jsonb_contains("metadata", r#"{"active": true}"#)
    .all()
    .await?;
// Generates: WHERE metadata @> '{"active": true}'::jsonb
Source

pub fn filter_jsonb_key_exists(self, field: &str, key: &str) -> QuerySet<T>

Filter by PostgreSQL JSONB key existence

Returns rows where the JSONB field contains the given key.

§Arguments
  • field - The JSONB field name
  • key - Key to check for existence
§Examples
// Find products with "sale_price" in metadata
let products = Product::objects()
    .filter_jsonb_key_exists("metadata", "sale_price")
    .all()
    .await?;
// Generates: WHERE metadata ? 'sale_price'
Source

pub fn filter_range_contains(self, field: &str, value: &str) -> QuerySet<T>

Filter by PostgreSQL range containment

Returns rows where the range field contains the given value.

§Arguments
  • field - The range field name
  • value - Value to check for containment in the range
§Examples
// Find events that include a specific date
let events = Event::objects()
    .filter_range_contains("date_range", "2024-06-15")
    .all()
    .await?;
// Generates: WHERE date_range @> '2024-06-15'

Trait Implementations§

Source§

impl<T> Clone for QuerySet<T>
where T: Clone + Model,

Source§

fn clone(&self) -> QuerySet<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Default for QuerySet<T>
where T: Model,

Source§

fn default() -> QuerySet<T>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for QuerySet<T>

§

impl<T> RefUnwindSafe for QuerySet<T>
where T: RefUnwindSafe,

§

impl<T> Send for QuerySet<T>

§

impl<T> Sync for QuerySet<T>

§

impl<T> Unpin for QuerySet<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for QuerySet<T>

§

impl<T> UnwindSafe for QuerySet<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Any for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Source§

fn type_name(&self) -> &'static str

Source§

impl<T> AnySync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> IntoResult<T> for T

Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more