Skip to content

Commit

Permalink
Use Self in structs
Browse files Browse the repository at this point in the history
  • Loading branch information
pawurb committed Jan 19, 2024
1 parent 111c909 commit 44549c5
Show file tree
Hide file tree
Showing 33 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/structs/all_locks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl Tabular for AllLocks {
const FILE_NAME: &'static str = "all_locks";

fn new(row: &Row) -> Self {
AllLocks {
Self {
pid: row.get::<_, Option<i32>>(0).unwrap_or_default().to_string(),
relname: row.get::<_, Option<String>>(1).unwrap_or_default(),
transactionid: row.get::<_, Option<String>>(2).unwrap_or_default(),
Expand Down
2 changes: 1 addition & 1 deletion src/structs/bloat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl Tabular for Bloat {
const FILE_NAME: &'static str = "bloat";

fn new(row: &Row) -> Self {
Bloat {
Self {
typefield: row.get::<_, Option<String>>(0).unwrap_or_default(),
schemaname: row.get::<_, Option<String>>(1).unwrap_or_default(),
object_name: row.get::<_, Option<String>>(2).unwrap_or_default(),
Expand Down
2 changes: 1 addition & 1 deletion src/structs/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl Tabular for Blocking {
const FILE_NAME: &'static str = "blocking";

fn new(row: &Row) -> Self {
Blocking {
Self {
blocked_pid: row.get::<_, Option<i32>>(0).unwrap_or_default(),
blocking_statement: row.get::<_, Option<String>>(1).unwrap_or_default(),
blocking_duration: row
Expand Down
2 changes: 1 addition & 1 deletion src/structs/buffercache_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl Tabular for BuffercacheStats {
const FILE_NAME: &'static str = "buffercache_stats";

fn new(row: &Row) -> Self {
BuffercacheStats {
Self {
relname: row.get::<_, Option<String>>(0).unwrap_or_default(),
buffered: row.get::<_, Option<String>>(1).unwrap_or_default(),
buffer_percent: row.get::<_, Option<Decimal>>(2).unwrap_or(dec!(0)),
Expand Down
2 changes: 1 addition & 1 deletion src/structs/buffercache_usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ impl Tabular for BuffercacheUsage {
const FILE_NAME: &'static str = "buffercache_usage";

fn new(row: &Row) -> Self {
BuffercacheUsage {
Self {
relname: row.get::<_, Option<String>>(0).unwrap_or_default(),
buffers: row.get::<_, Option<i64>>(1).unwrap_or_default(),
}
Expand Down
2 changes: 1 addition & 1 deletion src/structs/cache_hit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ impl Tabular for CacheHit {
const FILE_NAME: &'static str = "cache_hit";

fn new(row: &Row) -> Self {
CacheHit {
Self {
name: row.get::<_, Option<String>>(0).unwrap_or_default(),
ratio: row.get::<_, Option<Decimal>>(1).unwrap_or(dec!(0)),
}
Expand Down
2 changes: 1 addition & 1 deletion src/structs/calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl Tabular for Calls {
const FILE_NAME: &'static str = "calls";

fn new(row: &Row) -> Self {
Calls {
Self {
qry: row.get::<_, Option<String>>(0).unwrap_or_default(),
exec_time: row
.get::<_, Option<Interval>>(1)
Expand Down
2 changes: 1 addition & 1 deletion src/structs/connections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ impl Tabular for Connections {
const FILE_NAME: &'static str = "connections";

fn new(row: &Row) -> Self {
Connections {
Self {
username: row.get::<_, Option<String>>(0).unwrap_or_default(),
pid: row.get::<_, Option<i32>>(1).unwrap_or_default(),
client_addr: row.get::<_, Option<String>>(2).unwrap_or_default(),
Expand Down
2 changes: 1 addition & 1 deletion src/structs/db_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ impl Tabular for DbSetting {
const FILE_NAME: &'static str = "db_settings";

fn new(row: &Row) -> Self {
DbSetting {
Self {
name: row.get::<_, Option<String>>(0).unwrap_or_default(),
setting: row.get::<_, Option<String>>(1).unwrap_or_default(),
unit: row.get::<_, Option<String>>(2).unwrap_or_default(),
Expand Down
2 changes: 1 addition & 1 deletion src/structs/duplicate_indexes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl Tabular for DuplicateIndexes {
const FILE_NAME: &'static str = "duplicate_indexes";

fn new(row: &Row) -> Self {
DuplicateIndexes {
Self {
size: row.get::<_, Option<String>>(0).unwrap_or_default(),
idx1: row.get::<_, Option<String>>(1).unwrap_or_default(),
idx2: row.get::<_, Option<String>>(2).unwrap_or_default(),
Expand Down
2 changes: 1 addition & 1 deletion src/structs/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ impl Tabular for Extensions {
const FILE_NAME: &'static str = "extensions";

fn new(row: &Row) -> Self {
Extensions {
Self {
name: row.get::<_, Option<String>>(0).unwrap_or_default(),
default_version: row.get::<_, Option<String>>(1).unwrap_or_default(),
installed_version: row.get::<_, Option<String>>(2).unwrap_or_default(),
Expand Down
2 changes: 1 addition & 1 deletion src/structs/index_cache_hit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl Tabular for IndexCacheHit {
const FILE_NAME: &'static str = "index_cache_hit";

fn new(row: &Row) -> Self {
IndexCacheHit {
Self {
name: row.get::<_, Option<String>>(0).unwrap_or_default(),
buffer_hits: row.get::<_, Option<i64>>(1).unwrap_or_default(),
block_reads: row.get::<_, Option<i64>>(2).unwrap_or_default(),
Expand Down
2 changes: 1 addition & 1 deletion src/structs/index_scans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl Tabular for IndexScans {
const FILE_NAME: &'static str = "index_scans";

fn new(row: &Row) -> Self {
IndexScans {
Self {
schemaname: row.get::<_, Option<String>>(0).unwrap_or_default(),
tablename: row.get::<_, Option<String>>(1).unwrap_or_default(),
indexname: row.get::<_, Option<String>>(2).unwrap_or_default(),
Expand Down
2 changes: 1 addition & 1 deletion src/structs/index_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ impl Tabular for IndexSize {
const FILE_NAME: &'static str = "index_size";

fn new(row: &Row) -> Self {
IndexSize {
Self {
name: row.get::<_, Option<String>>(0).unwrap_or_default(),
size: row.get::<_, Option<String>>(1).unwrap_or_default(),
schema: row.get::<_, Option<String>>(2).unwrap_or_default(),
Expand Down
2 changes: 1 addition & 1 deletion src/structs/index_usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ impl Tabular for IndexUsage {
const FILE_NAME: &'static str = "index_usage";

fn new(row: &Row) -> Self {
IndexUsage {
Self {
relname: row.get::<_, Option<String>>(0).unwrap_or_default(),
percent_of_times_index_used: row.get::<_, Option<String>>(1).unwrap_or_default(),
rows_in_table: row.get::<_, Option<i64>>(2).unwrap_or_default(),
Expand Down
2 changes: 1 addition & 1 deletion src/structs/indexes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ impl Tabular for Indexes {
const FILE_NAME: &'static str = "indexes";

fn new(row: &Row) -> Self {
Indexes {
Self {
schemaname: row.get::<_, Option<String>>(0).unwrap_or_default(),
indexname: row.get::<_, Option<String>>(1).unwrap_or_default(),
tablename: row.get::<_, Option<String>>(2).unwrap_or_default(),
Expand Down
2 changes: 1 addition & 1 deletion src/structs/locks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl Tabular for Locks {
const FILE_NAME: &'static str = "locks";

fn new(row: &Row) -> Self {
Locks {
Self {
pid: row.get::<_, Option<i32>>(0).unwrap_or_default().to_string(),
relname: row.get::<_, Option<String>>(1).unwrap_or_default(),
transactionid: row.get::<_, Option<String>>(2).unwrap_or_default(),
Expand Down
2 changes: 1 addition & 1 deletion src/structs/long_running_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ impl Tabular for LongRunningQueries {
const FILE_NAME: &'static str = "long_running_queries";

fn new(row: &Row) -> Self {
LongRunningQueries {
Self {
pid: row.get::<_, Option<i32>>(0).unwrap_or_default().to_string(),
duration: row
.get::<_, Option<Interval>>(1)
Expand Down
2 changes: 1 addition & 1 deletion src/structs/mandelbrot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ impl Tabular for Mandelbrot {
const FILE_NAME: &'static str = "mandelbrot";

fn new(row: &Row) -> Self {
Mandelbrot {
Self {
array_to_string: row.get::<_, Option<String>>(0).unwrap_or_default(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/structs/null_indexes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl Tabular for NullIndexes {
const FILE_NAME: &'static str = "null_indexes";

fn new(row: &Row) -> Self {
NullIndexes {
Self {
oid: row.get::<_, Option<u32>>(0).unwrap_or_default().to_string(),
index: row.get::<_, Option<String>>(1).unwrap_or_default(),
index_size: row.get::<_, Option<String>>(2).unwrap_or_default(),
Expand Down
2 changes: 1 addition & 1 deletion src/structs/outliers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl Tabular for Outliers {
const FILE_NAME: &'static str = "outliers";

fn new(row: &Row) -> Self {
Outliers {
Self {
total_exec_time: row
.get::<_, Option<Interval>>(0)
.unwrap_or(get_default_interval()),
Expand Down
2 changes: 1 addition & 1 deletion src/structs/records_rank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ impl Tabular for RecordsRank {
const FILE_NAME: &'static str = "records_rank";

fn new(row: &Row) -> Self {
RecordsRank {
Self {
name: row.get::<_, Option<String>>(0).unwrap_or_default(),
esiimated_count: row.get::<_, Option<i64>>(1).unwrap_or_default(),
}
Expand Down
2 changes: 1 addition & 1 deletion src/structs/seq_scans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ impl Tabular for SeqScans {
const FILE_NAME: &'static str = "seq_scans";

fn new(row: &Row) -> Self {
SeqScans {
Self {
name: row.get::<_, Option<String>>(0).unwrap_or_default(),
count: row.get::<_, Option<i64>>(1).unwrap_or_default(),
}
Expand Down
2 changes: 1 addition & 1 deletion src/structs/ssl_used.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ impl Tabular for SslUsed {
const FILE_NAME: &'static str = "ssl_used";

fn new(row: &Row) -> Self {
SslUsed {
Self {
ssl_used: row.get::<_, Option<bool>>(0).unwrap_or_default(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/structs/table_cache_hit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl Tabular for TableCacheHit {
const FILE_NAME: &'static str = "table_cache_hit";

fn new(row: &Row) -> Self {
TableCacheHit {
Self {
name: row.get::<_, Option<String>>(0).unwrap_or_default(),
buffer_hits: row.get::<_, Option<i64>>(1).unwrap_or_default(),
block_reads: row.get::<_, Option<i64>>(2).unwrap_or_default(),
Expand Down
2 changes: 1 addition & 1 deletion src/structs/table_index_scans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ impl Tabular for TableIndexScans {
const FILE_NAME: &'static str = "table_index_scans";

fn new(row: &Row) -> Self {
TableIndexScans {
Self {
name: row.get::<_, Option<String>>(0).unwrap_or_default(),
count: row.get::<_, Option<i64>>(1).unwrap_or_default(),
}
Expand Down
2 changes: 1 addition & 1 deletion src/structs/table_indexes_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ impl Tabular for TableIndexesSize {
const FILE_NAME: &'static str = "table_indexes_size";

fn new(row: &Row) -> Self {
TableIndexesSize {
Self {
table: row.get::<_, Option<String>>(0).unwrap_or_default(),
index_size: row.get::<_, Option<String>>(1).unwrap_or_default(),
}
Expand Down
2 changes: 1 addition & 1 deletion src/structs/table_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ impl Tabular for TableSize {
const FILE_NAME: &'static str = "table_size";

fn new(row: &Row) -> Self {
TableSize {
Self {
name: row.get::<_, Option<String>>(0).unwrap_or_default(),
size: row.get::<_, Option<String>>(1).unwrap_or_default(),
schema: row.get::<_, Option<String>>(2).unwrap_or_default(),
Expand Down
2 changes: 1 addition & 1 deletion src/structs/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ impl Tabular for Tables {
const FILE_NAME: &'static str = "tables";

fn new(row: &Row) -> Self {
Tables {
Self {
tablename: row.get::<_, Option<String>>(0).unwrap_or_default(),
schemaname: row.get::<_, Option<String>>(1).unwrap_or_default(),
}
Expand Down
2 changes: 1 addition & 1 deletion src/structs/total_index_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ impl Tabular for TotalIndexSize {
const FILE_NAME: &'static str = "total_index_size";

fn new(row: &Row) -> Self {
TotalIndexSize {
Self {
size: row.get::<_, Option<String>>(0).unwrap_or_default(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/structs/total_table_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ impl Tabular for TotalTableSize {
const FILE_NAME: &'static str = "total_table_size";

fn new(row: &Row) -> Self {
TotalTableSize {
Self {
name: row.get::<_, Option<String>>(0).unwrap_or_default(),
size: row.get::<_, Option<String>>(1).unwrap_or_default(),
}
Expand Down
2 changes: 1 addition & 1 deletion src/structs/unused_indexes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ impl Tabular for UnusedIndexes {
const FILE_NAME: &'static str = "unused_indexes";

fn new(row: &Row) -> Self {
UnusedIndexes {
Self {
table: row.get::<_, Option<String>>(0).unwrap_or_default(),
index: row.get::<_, Option<String>>(1).unwrap_or_default(),
index_size: row.get::<_, Option<String>>(2).unwrap_or_default(),
Expand Down
2 changes: 1 addition & 1 deletion src/structs/vacuum_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl Tabular for VacuumStats {
const FILE_NAME: &'static str = "vacuum_stats";

fn new(row: &Row) -> Self {
VacuumStats {
Self {
schema: row.get::<_, Option<String>>(0).unwrap_or_default(),
table: row.get::<_, Option<String>>(1).unwrap_or_default(),
last_vacuum: row.get::<_, Option<String>>(2).unwrap_or_default(),
Expand Down

0 comments on commit 44549c5

Please sign in to comment.