pub struct QuerySet<T>where
T: Model,{ /* private fields */ }database and non-WebAssembly only.Expand description
Represents a query set.
Implementations§
Source§impl<T> QuerySet<T>where
T: Model,
impl<T> QuerySet<T>where
T: Model,
Sourcepub fn with_manager(manager: Arc<Manager<T>>) -> QuerySet<T>
pub fn with_manager(manager: Arc<Manager<T>>) -> QuerySet<T>
Sets the manager and returns self for chaining.
Sourcepub fn from_subquery<M, F>(builder: F, alias: &str) -> QuerySet<T>
pub fn from_subquery<M, F>(builder: F, alias: &str) -> QuerySet<T>
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 subqueryF- A closure that builds the subquery
§Parameters
builder- A closure that receives a freshQuerySet<M>and returns a configured QuerySetalias- 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 > 1Sourcepub fn inner_join<R>(self, left_field: &str, right_field: &str) -> QuerySet<T>where
R: Model,
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 implementModeltrait)
§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();Sourcepub fn left_join<R>(self, left_field: &str, right_field: &str) -> QuerySet<T>where
R: Model,
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();Sourcepub fn right_join<R>(self, left_field: &str, right_field: &str) -> QuerySet<T>where
R: Model,
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();Sourcepub fn cross_join<R>(self) -> QuerySet<T>where
R: Model,
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();Sourcepub fn from_as(self, alias: &str) -> QuerySet<T>
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();Sourcepub fn inner_join_on<R>(self, condition: &str) -> QuerySet<T>where
R: Model,
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 implementModeltrait)
§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();Sourcepub fn left_join_on<R>(self, condition: &str) -> QuerySet<T>where
R: Model,
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 implementModeltrait)
§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();Sourcepub fn right_join_on<R>(self, condition: &str) -> QuerySet<T>where
R: Model,
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 implementModeltrait)
§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();Sourcepub fn inner_join_as<R, F>(
self,
left_alias: &str,
right_alias: &str,
condition_fn: F,
) -> QuerySet<T>
pub fn inner_join_as<R, F>( self, left_alias: &str, right_alias: &str, condition_fn: F, ) -> QuerySet<T>
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 implementModeltrait)F- Closure that builds the JOIN ON condition
§Parameters
alias- Alias name for the target tablecondition_fn- Closure that receives aJoinOnBuilderand 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.
Sourcepub fn left_join_as<R, F>(
self,
left_alias: &str,
right_alias: &str,
condition_fn: F,
) -> QuerySet<T>
pub fn left_join_as<R, F>( self, left_alias: &str, right_alias: &str, condition_fn: F, ) -> QuerySet<T>
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 implementModeltrait)F- Closure that builds the JOIN ON condition
§Parameters
alias- Alias name for the target tablecondition_fn- Closure that receives aJoinOnBuilderand 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.
Sourcepub fn right_join_as<R, F>(
self,
left_alias: &str,
right_alias: &str,
condition_fn: F,
) -> QuerySet<T>
pub fn right_join_as<R, F>( self, left_alias: &str, right_alias: &str, condition_fn: F, ) -> QuerySet<T>
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 implementModeltrait)F- Closure that builds the JOIN ON condition
§Parameters
alias- Alias name for the target tablecondition_fn- Closure that receives aJoinOnBuilderand 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.
Sourcepub fn group_by<F>(self, selector_fn: F) -> QuerySet<T>
pub fn group_by<F>(self, selector_fn: F) -> QuerySet<T>
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 aGroupByBuilderand 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.
Sourcepub 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,
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 aHavingFieldSelectorand returns it with the field setoperator- 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.
Sourcepub fn having_count<F>(self, expr_fn: F) -> QuerySet<T>
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 aHavingFieldSelectorand returns it with the field setoperator- 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.
Sourcepub 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,
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 aHavingFieldSelectorand returns it with the field setoperator- 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.
Sourcepub 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,
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 fieldFE- Expression closure that builds the comparison expression
§Parameters
field_selector- Closure that selects the field from the modelexpr_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();Sourcepub 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,
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 fieldFE- Expression closure that builds the comparison expression
§Parameters
field_selector- Closure that selects the field from the modelexpr_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();Sourcepub fn filter_in_subquery<R, F>(
self,
field: &str,
subquery_fn: F,
) -> QuerySet<T>
pub fn filter_in_subquery<R, F>( self, field: &str, subquery_fn: F, ) -> QuerySet<T>
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 implementModeltrait)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?;Sourcepub fn filter_not_in_subquery<R, F>(
self,
field: &str,
subquery_fn: F,
) -> QuerySet<T>
pub fn filter_not_in_subquery<R, F>( self, field: &str, subquery_fn: F, ) -> QuerySet<T>
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?;Sourcepub fn filter_exists<R, F>(self, subquery_fn: F) -> QuerySet<T>
pub fn filter_exists<R, F>(self, subquery_fn: F) -> QuerySet<T>
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?;Sourcepub fn filter_not_exists<R, F>(self, subquery_fn: F) -> QuerySet<T>
pub fn filter_not_exists<R, F>(self, subquery_fn: F) -> QuerySet<T>
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?;Sourcepub fn with_cte(self, cte: CTE) -> QuerySet<T>
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?;Sourcepub fn with_lateral_join(self, join: LateralJoin) -> QuerySet<T>
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 = $1Eagerly 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)Sourcepub async fn all(&self) -> Result<Vec<T>, Error>where
T: DeserializeOwned,
pub async fn all(&self) -> Result<Vec<T>, Error>where
T: DeserializeOwned,
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
Sourcepub async fn first(&self) -> Result<Option<T>, Error>where
T: DeserializeOwned,
pub async fn first(&self) -> Result<Option<T>, Error>where
T: DeserializeOwned,
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"),
}Sourcepub async fn get(&self) -> Result<T, Error>where
T: DeserializeOwned,
pub async fn get(&self) -> Result<T, Error>where
T: DeserializeOwned,
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
Sourcepub async fn all_with_db(
&self,
conn: &DatabaseConnection,
) -> Result<Vec<T>, Error>where
T: DeserializeOwned,
pub async fn all_with_db(
&self,
conn: &DatabaseConnection,
) -> Result<Vec<T>, Error>where
T: DeserializeOwned,
Execute the queryset with an explicit database connection and return all records
§Examples
let users = User::objects()
.all()
.all_with_db(&db)
.await?;Sourcepub async fn get_with_db(&self, conn: &DatabaseConnection) -> Result<T, Error>where
T: DeserializeOwned,
pub async fn get_with_db(&self, conn: &DatabaseConnection) -> Result<T, Error>where
T: DeserializeOwned,
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?;Sourcepub async fn first_with_db(
&self,
conn: &DatabaseConnection,
) -> Result<Option<T>, Error>where
T: DeserializeOwned,
pub async fn first_with_db(
&self,
conn: &DatabaseConnection,
) -> Result<Option<T>, Error>where
T: DeserializeOwned,
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?;Sourcepub async fn count(&self) -> Result<usize, Error>
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);Sourcepub async fn exists(&self) -> Result<bool, Error>
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");
}Sourcepub async fn create(&self, object: T) -> Result<T, Error>
pub async fn create(&self, object: T) -> Result<T, Error>
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?;Sourcepub fn update_query(
&self,
updates: &HashMap<String, UpdateValue>,
) -> UpdateStatement
pub fn update_query( &self, updates: &HashMap<String, UpdateValue>, ) -> UpdateStatement
Generate UPDATE statement using reinhardt-query
Sourcepub fn update_sql(
&self,
updates: &HashMap<String, UpdateValue>,
) -> (String, Vec<String>)
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"]Sourcepub fn delete_query(&self) -> DeleteStatement
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
Sourcepub fn delete_sql(&self) -> (String, Vec<String>)
pub fn delete_sql(&self) -> (String, Vec<String>)
Deletes sql.
Sourcepub async fn get_composite(
&self,
pk_values: &HashMap<String, PkValue>,
) -> Result<T, Error>
pub async fn get_composite( &self, pk_values: &HashMap<String, PkValue>, ) -> Result<T, Error>
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)
Sourcepub fn annotate(self, annotation: Annotation) -> QuerySet<T>
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?;Sourcepub fn annotate_subquery<M, F>(self, name: &str, builder: F) -> QuerySet<T>
pub fn annotate_subquery<M, F>(self, name: &str, builder: F) -> QuerySet<T>
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 subqueryF- A closure that builds the subquery
§Parameters
name- The alias for the subquery result columnbuilder- A closure that receives a freshQuerySet<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 authorsSourcepub fn aggregate(self, aggregate: Aggregate) -> QuerySet<T>
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?;Sourcepub fn values(self, fields: &[&str]) -> QuerySet<T>
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?;Sourcepub fn values_list(self, fields: &[&str]) -> QuerySet<T>
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?;Sourcepub fn order_by(self, fields: &[&str]) -> QuerySet<T>
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"]);Sourcepub fn limit(self, limit: usize) -> QuerySet<T>
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?;Sourcepub fn offset(self, offset: usize) -> QuerySet<T>
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?;Sourcepub fn paginate(self, page: usize, page_size: usize) -> QuerySet<T>
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?;Sourcepub fn as_subquery(self) -> String
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)Sourcepub fn defer(self, fields: &[&str]) -> QuerySet<T>
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)Sourcepub fn only(self, fields: &[&str]) -> QuerySet<T>
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 usersSourcepub fn full_text_search(self, field: &str, query: &str) -> QuerySet<T>
pub fn full_text_search(self, field: &str, query: &str) -> QuerySet<T>
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 searchquery- 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')Sourcepub fn filter_array_overlap(self, field: &str, values: &[&str]) -> QuerySet<T>
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 namevalues- 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']Sourcepub fn filter_array_contains(self, field: &str, values: &[&str]) -> QuerySet<T>
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 namevalues- 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']Sourcepub fn filter_jsonb_contains(self, field: &str, json: &str) -> QuerySet<T>
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 namejson- 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}'::jsonbSourcepub fn filter_jsonb_key_exists(self, field: &str, key: &str) -> QuerySet<T>
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 namekey- 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'Sourcepub fn filter_range_contains(self, field: &str, value: &str) -> QuerySet<T>
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 namevalue- 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§
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>where
T: UnwindSafe + RefUnwindSafe,
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
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
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
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
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.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
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.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
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.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
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.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
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.