Skip to main content

kellnr_db/
provider.rs

1use std::path::Path;
2
3use chrono::{DateTime, Utc};
4use crate_meta::CrateMeta;
5use kellnr_common::crate_data::CrateData;
6use kellnr_common::crate_overview::CrateOverview;
7use kellnr_common::cratesio_prefetch_msg::CratesioPrefetchMsg;
8use kellnr_common::index_metadata::IndexMetadata;
9use kellnr_common::normalized_name::NormalizedName;
10use kellnr_common::original_name::OriginalName;
11use kellnr_common::prefetch::Prefetch;
12use kellnr_common::publish_metadata::PublishMetadata;
13use kellnr_common::version::Version;
14use kellnr_common::webhook::{Webhook, WebhookEvent, WebhookQueue};
15use sea_orm::prelude::async_trait::async_trait;
16use serde::{Deserialize, Serialize};
17
18use crate::error::DbError;
19use crate::{AuthToken, CrateSummary, DocQueueEntry, Group, User, crate_meta};
20
21pub type DbResult<T> = Result<T, DbError>;
22
23#[derive(Debug, PartialEq, Eq)]
24pub enum PrefetchState {
25    /// The client's cached index is current. Carries the validators stored in
26    /// the database, which are the only ones that may be sent upstream.
27    UpToDate {
28        etag: String,
29        last_modified: String,
30    },
31    NeedsUpdate(Prefetch),
32    NotFound,
33}
34
35/// Which download-restricted crates a caller may see in crate listings.
36#[derive(Debug, Clone, PartialEq, Eq)]
37pub enum CrateVisibility {
38    /// All crates, used for admins.
39    All,
40    /// Unrestricted crates and the restricted crates the user owns or may
41    /// access as crate user or crate group member.
42    User(String),
43    /// Unrestricted crates only, used for anonymous callers.
44    Unrestricted,
45}
46
47/// Authenticated user and privileges resolved from a valid session cookie.
48#[derive(Debug, Clone, PartialEq, Eq)]
49pub struct SessionInfo {
50    pub name: String,
51    pub is_admin: bool,
52    pub is_read_only: bool,
53}
54
55/// Data stored during `OAuth2` authentication flow for CSRF/PKCE verification
56#[derive(Debug, Clone, PartialEq, Eq)]
57pub struct OAuth2StateData {
58    pub state: String,
59    pub pkce_verifier: String,
60    pub nonce: String,
61}
62
63/// Information about an individual toolchain component (e.g., rustc, cargo)
64#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, utoipa::ToSchema)]
65pub struct ToolchainComponentInfo {
66    /// Component name (e.g., "rustc", "cargo", "rust-std-x86_64-unknown-linux-gnu")
67    pub name: String,
68    /// Path to the stored component archive
69    pub storage_path: String,
70    /// SHA256 hash of the component archive
71    pub hash: String,
72    /// Component archive size in bytes
73    pub size: i64,
74}
75
76impl From<kellnr_entity::toolchain_component::Model> for ToolchainComponentInfo {
77    fn from(c: kellnr_entity::toolchain_component::Model) -> Self {
78        Self {
79            name: c.name,
80            storage_path: c.storage_path,
81            hash: c.hash,
82            size: c.size,
83        }
84    }
85}
86
87/// Toolchain target information (e.g., a specific archive for a target triple)
88#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, utoipa::ToSchema)]
89pub struct ToolchainTargetInfo {
90    /// Target ID
91    pub id: i64,
92    /// Target triple (e.g., "x86_64-unknown-linux-gnu")
93    pub target: String,
94    /// Path to the stored archive
95    pub storage_path: String,
96    /// SHA256 hash of the archive
97    pub hash: String,
98    /// Archive size in bytes
99    pub size: i64,
100    /// Processing status: "processing", "ready", or "failed"
101    pub status: String,
102    /// Individual components extracted from the combined archive
103    pub components: Vec<ToolchainComponentInfo>,
104}
105
106/// Toolchain with all its targets
107#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, utoipa::ToSchema)]
108pub struct ToolchainWithTargets {
109    /// Toolchain ID
110    pub id: i64,
111    /// Toolchain name (e.g., "rust")
112    pub name: String,
113    /// Toolchain version (e.g., "1.75.0")
114    pub version: String,
115    /// Release date
116    pub date: String,
117    /// Channel (e.g., "stable", "beta", "nightly")
118    pub channel: Option<String>,
119    /// Creation timestamp
120    pub created: String,
121    /// Available targets for this toolchain
122    pub targets: Vec<ToolchainTargetInfo>,
123}
124
125/// Channel information (e.g., "stable" -> "1.75.0")
126#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, utoipa::ToSchema)]
127pub struct ChannelInfo {
128    /// Channel name (e.g., "stable", "beta", "nightly")
129    pub name: String,
130    /// Toolchain version pointed to by this channel
131    pub version: String,
132    /// Release date
133    pub date: String,
134}
135
136#[async_trait]
137pub trait DbProvider: Send + Sync {
138    async fn get_last_updated_crate(
139        &self,
140        visibility: &CrateVisibility,
141    ) -> DbResult<Option<(OriginalName, Version)>>;
142    async fn authenticate_user(&self, name: &str, pwd: &str) -> DbResult<User>;
143    async fn increase_download_counter(
144        &self,
145        crate_name: &NormalizedName,
146        crate_version: &Version,
147    ) -> DbResult<()>;
148    async fn increase_cached_download_counter(
149        &self,
150        crate_name: &NormalizedName,
151        crate_version: &Version,
152    ) -> DbResult<()>;
153    async fn increase_download_counter_by(
154        &self,
155        crate_name: &NormalizedName,
156        crate_version: &Version,
157        count: u64,
158    ) -> DbResult<()>;
159    async fn increase_cached_download_counter_by(
160        &self,
161        crate_name: &NormalizedName,
162        crate_version: &Version,
163        count: u64,
164    ) -> DbResult<()>;
165    async fn validate_session(&self, session_token: &str) -> DbResult<SessionInfo>;
166    /// Delete all sessions that have outlived the configured session age.
167    /// Returns the number of rows removed.
168    async fn delete_expired_sessions(&self) -> DbResult<u64>;
169    async fn add_session_token(&self, name: &str, session_token: &str) -> DbResult<()>;
170    /// Delete all sessions of a user. Returns the number of rows removed.
171    async fn delete_user_sessions(&self, user_name: &str) -> DbResult<u64>;
172    /// Delete all sessions of a user except `keep_session_token`. Returns the
173    /// number of rows removed.
174    async fn delete_other_user_sessions(
175        &self,
176        user_name: &str,
177        keep_session_token: &str,
178    ) -> DbResult<u64>;
179    async fn add_crate_user(&self, crate_name: &NormalizedName, user: &str) -> DbResult<()>;
180    async fn add_owner(&self, crate_name: &NormalizedName, owner: &str) -> DbResult<()>;
181    async fn is_download_restricted(&self, crate_name: &NormalizedName) -> DbResult<bool>;
182    async fn change_download_restricted(
183        &self,
184        crate_name: &NormalizedName,
185        restricted: bool,
186    ) -> DbResult<()>;
187    async fn is_crate_user(&self, crate_name: &NormalizedName, user: &str) -> DbResult<bool>;
188    async fn is_owner(&self, crate_name: &NormalizedName, user: &str) -> DbResult<bool>;
189    async fn get_crate_id(&self, crate_name: &NormalizedName) -> DbResult<Option<i64>>;
190    async fn get_crate_owners(&self, crate_name: &NormalizedName) -> DbResult<Vec<User>>;
191    async fn get_crate_users(&self, crate_name: &NormalizedName) -> DbResult<Vec<User>>;
192    async fn get_crate_versions(&self, crate_name: &NormalizedName) -> DbResult<Vec<Version>>;
193    async fn delete_session_token(&self, session_token: &str) -> DbResult<()>;
194    async fn delete_user(&self, user_name: &str) -> DbResult<()>;
195    async fn change_pwd(&self, user_name: &str, new_pwd: &str) -> DbResult<()>;
196    async fn change_read_only_state(&self, user_name: &str, state: bool) -> DbResult<()>;
197    async fn change_admin_state(&self, user_name: &str, state: bool) -> DbResult<()>;
198    async fn crate_version_exists(&self, crate_id: i64, version: &str) -> DbResult<bool>;
199    async fn get_max_version_from_id(&self, crate_id: i64) -> DbResult<Version>;
200    async fn get_max_version_from_name(&self, crate_name: &NormalizedName) -> DbResult<Version>;
201    async fn update_max_version(&self, crate_id: i64, version: &Version) -> DbResult<()>;
202    async fn add_auth_token(&self, name: &str, token: &str, user: &str) -> DbResult<()>;
203    async fn get_user_from_token(&self, token: &str) -> DbResult<User>;
204    async fn get_user(&self, name: &str) -> DbResult<User>;
205    async fn get_auth_tokens(&self, user_name: &str) -> DbResult<Vec<AuthToken>>;
206    async fn delete_auth_token(&self, id: i32) -> DbResult<()>;
207    async fn delete_owner(&self, crate_name: &str, owner: &str) -> DbResult<()>;
208    async fn delete_crate_user(&self, crate_name: &NormalizedName, user: &str) -> DbResult<()>;
209    async fn add_user(
210        &self,
211        name: &str,
212        pwd: &str,
213        is_admin: bool,
214        is_read_only: bool,
215    ) -> DbResult<()>;
216    async fn get_users(&self) -> DbResult<Vec<User>>;
217    async fn add_group(&self, name: &str) -> DbResult<()>;
218    async fn get_group(&self, name: &str) -> DbResult<Group>;
219    async fn get_groups(&self) -> DbResult<Vec<Group>>;
220    async fn delete_group(&self, name: &str) -> DbResult<()>;
221    async fn add_group_user(&self, group_name: &str, user: &str) -> DbResult<()>;
222    async fn delete_group_user(&self, group_name: &str, user: &str) -> DbResult<()>;
223    async fn get_group_users(&self, group_name: &str) -> DbResult<Vec<User>>;
224    async fn is_group_user(&self, group_name: &str, group: &str) -> DbResult<bool>;
225    async fn add_crate_group(&self, crate_name: &NormalizedName, group: &str) -> DbResult<()>;
226    async fn delete_crate_group(&self, crate_name: &NormalizedName, group: &str) -> DbResult<()>;
227    async fn get_crate_groups(&self, crate_name: &NormalizedName) -> DbResult<Vec<Group>>;
228    async fn is_crate_group(&self, crate_name: &NormalizedName, group: &str) -> DbResult<bool>;
229    async fn is_crate_group_user(&self, crate_name: &NormalizedName, user: &str) -> DbResult<bool>;
230    async fn get_total_unique_crates(&self) -> DbResult<u64>;
231    async fn get_total_crate_versions(&self) -> DbResult<u64>;
232    async fn get_total_downloads(&self) -> DbResult<u64>;
233    async fn get_top_crates_downloads(
234        &self,
235        top: u64,
236        visibility: &CrateVisibility,
237    ) -> DbResult<Vec<(String, u64)>>;
238    async fn get_total_unique_cached_crates(&self) -> DbResult<u64>;
239    async fn get_total_cached_crate_versions(&self) -> DbResult<u64>;
240    async fn get_total_cached_downloads(&self) -> DbResult<u64>;
241    async fn get_crate_summaries(&self) -> DbResult<Vec<CrateSummary>>;
242    async fn add_doc_queue(
243        &self,
244        krate: &NormalizedName,
245        version: &Version,
246        path: &Path,
247    ) -> DbResult<()>;
248    async fn delete_doc_queue(&self, id: i64) -> DbResult<()>;
249    async fn get_doc_queue(&self) -> DbResult<Vec<DocQueueEntry>>;
250    async fn delete_crate(&self, krate: &NormalizedName, version: &Version) -> DbResult<()>;
251    async fn get_crate_meta_list(&self, crate_name: &NormalizedName) -> DbResult<Vec<CrateMeta>>;
252    async fn update_last_updated(&self, id: i64, last_updated: &DateTime<Utc>) -> DbResult<()>;
253    async fn search_in_crate_name_and_description(
254        &self,
255        contains: &str,
256        limit: u64,
257        offset: u64,
258        cache: bool,
259        visibility: &CrateVisibility,
260    ) -> DbResult<Vec<CrateOverview>>;
261    async fn count_by_crate_name_and_description(
262        &self,
263        contains: &str,
264        cache: bool,
265        visibility: &CrateVisibility,
266    ) -> DbResult<u64>;
267    async fn get_crate_overview_list(
268        &self,
269        limit: u64,
270        offset: u64,
271        cache: bool,
272        visibility: &CrateVisibility,
273    ) -> DbResult<Vec<CrateOverview>>;
274    async fn get_crate_data(&self, crate_name: &NormalizedName) -> DbResult<CrateData>;
275    async fn add_empty_crate(&self, name: &str, created: &DateTime<Utc>) -> DbResult<i64>;
276    async fn add_crate(
277        &self,
278        pub_metadata: &PublishMetadata,
279        cksum: &str,
280        created: &DateTime<Utc>,
281        owner: &str,
282    ) -> DbResult<i64>;
283    async fn update_docs_link(
284        &self,
285        crate_name: &NormalizedName,
286        version: &Version,
287        docs_link: &str,
288    ) -> DbResult<()>;
289    async fn add_crate_metadata(
290        &self,
291        pub_metadata: &PublishMetadata,
292        created: &str,
293        crate_id: i64,
294    ) -> DbResult<()>;
295    async fn get_prefetch_data(&self, crate_name: &str) -> DbResult<Prefetch>;
296    async fn is_cratesio_cache_up_to_date(
297        &self,
298        crate_name: &NormalizedName,
299        if_none_match: Option<String>,
300        if_modified_since: Option<String>,
301    ) -> DbResult<PrefetchState>;
302    async fn add_cratesio_prefetch_data(
303        &self,
304        crate_name: &OriginalName,
305        etag: &str,
306        last_modified: &str,
307        description: Option<String>,
308        indices: &[IndexMetadata],
309    ) -> DbResult<Prefetch>;
310    async fn get_cratesio_index_update_list(&self) -> DbResult<Vec<CratesioPrefetchMsg>>;
311    /// Checksum of a crates.io crate version from the cached index, if known.
312    async fn get_cratesio_cksum(
313        &self,
314        crate_name: &NormalizedName,
315        version: &Version,
316    ) -> DbResult<Option<String>>;
317    async fn unyank_crate(&self, crate_name: &NormalizedName, version: &Version) -> DbResult<()>;
318    async fn yank_crate(&self, crate_name: &NormalizedName, version: &Version) -> DbResult<()>;
319    async fn register_webhook(&self, webhook: Webhook) -> DbResult<String>;
320    async fn delete_webhook(&self, id: &str) -> DbResult<()>;
321    async fn get_webhook(&self, id: &str) -> DbResult<Webhook>;
322    async fn get_all_webhooks(&self) -> DbResult<Vec<Webhook>>;
323    /// Creates a new webhook queue entry for each register webhook
324    /// matching the given event. `Next_attempt` is set to current time,
325    ///  in order to trigger immediate dispatch.
326    async fn add_webhook_queue(
327        &self,
328        event: WebhookEvent,
329        payload: serde_json::Value,
330    ) -> DbResult<()>;
331    /// Extracts webhook queue entries with `next_attempt` at or earlier than provided timestamp.
332    async fn get_pending_webhook_queue_entries(
333        &self,
334        timestamp: DateTime<Utc>,
335    ) -> DbResult<Vec<WebhookQueue>>;
336    async fn update_webhook_queue(
337        &self,
338        id: &str,
339        last_attempt: DateTime<Utc>,
340        next_attempt: DateTime<Utc>,
341    ) -> DbResult<()>;
342    async fn delete_webhook_queue(&self, id: &str) -> DbResult<()>;
343
344    // `OAuth2` identity methods
345    /// Look up a user by their `OAuth2` identity (issuer + subject)
346    async fn get_user_by_oauth2_identity(
347        &self,
348        issuer: &str,
349        subject: &str,
350    ) -> DbResult<Option<User>>;
351
352    /// Whether any admin user has an `OAuth2` identity linked.
353    ///
354    /// Used at startup to tell a usable SSO-only deployment apart from one that
355    /// has locked itself out: the default local admin always exists, so the
356    /// presence of an admin alone says nothing.
357    async fn has_oauth2_admin(&self) -> DbResult<bool>;
358
359    /// Create a new user from `OAuth2` authentication and link their identity
360    async fn create_oauth2_user(
361        &self,
362        username: &str,
363        issuer: &str,
364        subject: &str,
365        email: Option<String>,
366        is_admin: bool,
367        is_read_only: bool,
368    ) -> DbResult<User>;
369
370    /// Link an `OAuth2` identity to an existing user
371    async fn link_oauth2_identity(
372        &self,
373        user_id: i64,
374        issuer: &str,
375        subject: &str,
376        email: Option<String>,
377    ) -> DbResult<()>;
378
379    // `OAuth2` state methods (CSRF/PKCE during auth flow)
380    /// Store `OAuth2` state for CSRF/PKCE verification during auth flow
381    async fn store_oauth2_state(
382        &self,
383        state: &str,
384        pkce_verifier: &str,
385        nonce: &str,
386    ) -> DbResult<()>;
387
388    /// Retrieve and delete `OAuth2` state (single use)
389    async fn get_and_delete_oauth2_state(&self, state: &str) -> DbResult<Option<OAuth2StateData>>;
390
391    /// Clean up expired `OAuth2` states (older than 10 minutes)
392    async fn cleanup_expired_oauth2_states(&self) -> DbResult<u64>;
393
394    /// Check if username is available (for `OAuth2` auto-provisioning)
395    async fn is_username_available(&self, username: &str) -> DbResult<bool>;
396
397    // Toolchain distribution methods
398    /// Add a new toolchain release
399    async fn add_toolchain(
400        &self,
401        name: &str,
402        version: &str,
403        date: &str,
404        channel: Option<String>,
405    ) -> DbResult<i64>;
406
407    /// Add a target archive to an existing toolchain
408    async fn add_toolchain_target(
409        &self,
410        toolchain_id: i64,
411        target: &str,
412        storage_path: &str,
413        hash: &str,
414        size: i64,
415    ) -> DbResult<i64>;
416
417    /// Add a component to a toolchain target
418    async fn add_toolchain_component(
419        &self,
420        target_id: i64,
421        name: &str,
422        storage_path: &str,
423        hash: &str,
424        size: i64,
425    ) -> DbResult<()>;
426
427    /// Update the processing status of a toolchain target
428    async fn set_target_status(&self, target_id: i64, status: &str) -> DbResult<()>;
429
430    /// Get a toolchain by its channel (e.g., "stable", "nightly")
431    async fn get_toolchain_by_channel(
432        &self,
433        channel: &str,
434    ) -> DbResult<Option<ToolchainWithTargets>>;
435
436    /// Get a toolchain by name and version
437    async fn get_toolchain_by_version(
438        &self,
439        name: &str,
440        version: &str,
441    ) -> DbResult<Option<ToolchainWithTargets>>;
442
443    /// List all toolchains
444    async fn list_toolchains(&self) -> DbResult<Vec<ToolchainWithTargets>>;
445
446    /// Delete a toolchain and all its targets
447    async fn delete_toolchain(&self, name: &str, version: &str) -> DbResult<()>;
448
449    /// Delete a specific toolchain target
450    async fn delete_toolchain_target(
451        &self,
452        name: &str,
453        version: &str,
454        target: &str,
455    ) -> DbResult<()>;
456
457    /// Set a channel to point to a specific toolchain version
458    async fn set_channel(&self, channel: &str, name: &str, version: &str) -> DbResult<()>;
459
460    /// Get all channels with their current versions
461    async fn get_channels(&self) -> DbResult<Vec<ChannelInfo>>;
462}
463
464pub mod mock {
465    use chrono::DateTime;
466    use mockall::predicate::*;
467    use mockall::*;
468
469    use super::*;
470
471    mock! {
472          pub Db {}
473
474        #[async_trait]
475        impl DbProvider for Db {
476
477            async fn get_last_updated_crate(&self, visibility: &CrateVisibility) -> DbResult<Option<(OriginalName, Version)>> {
478                unimplemented!()
479            }
480
481            async fn authenticate_user(&self, _name: &str, _pwd: &str) -> DbResult<User> {
482                unimplemented!()
483            }
484
485            async fn increase_download_counter(
486                &self,
487                _crate_name: &NormalizedName,
488                _crate_version: &Version,
489            ) -> DbResult<()> {
490                unimplemented!()
491            }
492
493            async fn increase_cached_download_counter(
494                &self,
495                _crate_name: &NormalizedName,
496                _crate_version: &Version,
497            ) -> DbResult<()> {
498                unimplemented!()
499            }
500
501            async fn increase_download_counter_by(
502                &self,
503                _crate_name: &NormalizedName,
504                _crate_version: &Version,
505                _count: u64,
506            ) -> DbResult<()> {
507                unimplemented!()
508            }
509
510            async fn increase_cached_download_counter_by(
511                &self,
512                _crate_name: &NormalizedName,
513                _crate_version: &Version,
514                _count: u64,
515            ) -> DbResult<()> {
516                unimplemented!()
517            }
518
519            async fn validate_session(&self, _session_token: &str) -> DbResult<SessionInfo> {
520                unimplemented!()
521            }
522
523            async fn delete_expired_sessions(&self) -> DbResult<u64> {
524                unimplemented!()
525            }
526
527            async fn add_session_token(&self, _name: &str, _session_token: &str) -> DbResult<()> {
528                unimplemented!()
529            }
530
531            async fn delete_user_sessions(&self, _user_name: &str) -> DbResult<u64> {
532                unimplemented!()
533            }
534
535            async fn delete_other_user_sessions(&self, _user_name: &str, _keep_session_token: &str) -> DbResult<u64> {
536                unimplemented!()
537            }
538
539            async fn add_crate_user(&self, crate_name: &NormalizedName, user: &str) -> DbResult<()> {
540                unimplemented!()
541            }
542
543            async fn add_owner(&self, _crate_name: &NormalizedName, _owner: &str) -> DbResult<()> {
544                unimplemented!()
545            }
546
547            async fn is_download_restricted(&self, crate_name: &NormalizedName) -> DbResult<bool> {
548                unimplemented!()
549            }
550
551            async fn change_download_restricted(
552                &self,
553                crate_name: &NormalizedName,
554                restricted: bool,
555            ) -> DbResult<()> {
556                unimplemented!()
557            }
558
559            async fn is_crate_user(&self, _crate_name: &NormalizedName, _user: &str) -> DbResult<bool> {
560                unimplemented!()
561            }
562
563            async fn is_owner(&self, _crate_name: &NormalizedName, _user: &str) -> DbResult<bool> {
564                unimplemented!()
565            }
566
567            async fn get_crate_id(&self, _crate_name: &NormalizedName) -> DbResult<Option<i64>> {
568                unimplemented!()
569            }
570
571            async fn get_crate_owners(&self, _crate_name: &NormalizedName) -> DbResult<Vec<User>> {
572                unimplemented!()
573            }
574
575            async fn get_crate_users(&self, _crate_name: &NormalizedName) -> DbResult<Vec<User>> {
576                unimplemented!()
577            }
578
579            async fn get_crate_versions(&self, _crate_name: &NormalizedName) -> DbResult<Vec<Version>> {
580                unimplemented!()
581            }
582
583            async fn delete_session_token(&self, _session_token: &str) -> DbResult<()> {
584                unimplemented!()
585            }
586
587            async fn delete_user(&self, _user_name: &str) -> DbResult<()> {
588                unimplemented!()
589            }
590
591            async fn change_pwd(&self, _user_name: &str, _new_pwd: &str) -> DbResult<()> {
592                unimplemented!()
593            }
594
595            async fn change_read_only_state(&self, _user_name: &str, _state: bool) -> DbResult<()> {
596                unimplemented!()
597            }
598
599            async fn change_admin_state(&self, _user_name: &str, _state: bool) -> DbResult<()> {
600                unimplemented!()
601            }
602
603            async fn crate_version_exists(&self, _crate_id: i64, _version: &str) -> DbResult<bool> {
604                unimplemented!()
605            }
606
607            async fn get_max_version_from_id(&self, crate_id: i64) -> DbResult<Version>  {
608                unimplemented!()
609            }
610
611            async fn get_max_version_from_name(&self, crate_name: &NormalizedName) -> DbResult<Version> {
612                unimplemented!()
613            }
614
615            async fn update_max_version(&self, crate_id: i64, version: &Version) -> DbResult<()> {
616                unimplemented!()
617            }
618
619            async fn add_auth_token(&self, _name: &str, _token: &str, _user: &str) -> DbResult<()> {
620                unimplemented!()
621            }
622
623            async fn get_user_from_token(&self, _token: &str) -> DbResult<User> {
624                unimplemented!()
625            }
626
627            async fn get_user(&self, _name: &str) -> DbResult<User> {
628                unimplemented!()
629            }
630
631            async fn get_auth_tokens(&self, _user_name: &str) -> DbResult<Vec<AuthToken>> {
632                unimplemented!()
633            }
634
635            async fn delete_auth_token(&self, _id: i32) -> DbResult<()> {
636                unimplemented!()
637            }
638
639            async fn delete_owner(&self, _crate_name: &str, _owner: &str) -> DbResult<()> {
640                unimplemented!()
641            }
642
643            async fn delete_crate_user(&self, crate_name: &NormalizedName, user: &str) -> DbResult<()>{
644                unimplemented!()
645            }
646
647            async fn add_user(&self, _name: &str, _pwd: &str, _is_admin: bool, _is_read_only: bool) -> DbResult<()> {
648                unimplemented!()
649            }
650
651            async fn get_users(&self) -> DbResult<Vec<User>> {
652                unimplemented!()
653            }
654
655            async fn get_total_unique_crates(&self) -> DbResult<u64> {
656                unimplemented!()
657            }
658
659            async fn get_total_crate_versions(&self) -> DbResult<u64> {
660                unimplemented!()
661            }
662
663            async fn get_top_crates_downloads(&self, _top: u64, visibility: &CrateVisibility) -> DbResult<Vec<(String, u64)>> {
664                unimplemented!()
665            }
666
667            async fn get_total_unique_cached_crates(&self) -> DbResult<u64> {
668                unimplemented!()
669            }
670
671            async fn get_total_cached_crate_versions(&self) -> DbResult<u64> {
672                unimplemented!()
673            }
674
675            async fn get_total_cached_downloads(&self) -> DbResult<u64> {
676                unimplemented!()
677            }
678
679            async fn get_crate_summaries(&self) -> DbResult<Vec<CrateSummary >> {
680                unimplemented!()
681            }
682
683                async fn add_doc_queue(&self, krate: &NormalizedName, version: &Version, path: &Path) -> DbResult<()>{
684                    unimplemented!()
685                }
686
687            async fn delete_doc_queue(&self, id: i64) -> DbResult<()>{
688                    unimplemented!()
689                }
690
691            async fn get_doc_queue(&self) -> DbResult<Vec<DocQueueEntry>> {
692                unimplemented!()
693            }
694
695            async fn delete_crate(&self, krate: &NormalizedName, version: &Version) -> DbResult<()> {
696                unimplemented!()
697            }
698
699            async fn get_total_downloads(&self) -> DbResult<u64>{
700                unimplemented!()
701            }
702
703            async fn get_crate_meta_list(&self, crate_name: &NormalizedName) -> DbResult<Vec<CrateMeta>>{
704                unimplemented!()
705            }
706
707            async fn update_last_updated(&self, id: i64, last_updated: &DateTime<Utc>) -> DbResult<()>{
708                unimplemented!()
709            }
710
711            async fn search_in_crate_name_and_description(&self, contains: &str, limit: u64, offset: u64, cache: bool, visibility: &CrateVisibility) -> DbResult<Vec<CrateOverview>> {
712                unimplemented!()
713            }
714
715            async fn count_by_crate_name_and_description(&self, contains: &str, cache: bool, visibility: &CrateVisibility) -> DbResult<u64> {
716                unimplemented!()
717            }
718
719            async fn get_crate_overview_list(&self, limit: u64, offset: u64, cache: bool, visibility: &CrateVisibility) -> DbResult<Vec<CrateOverview >> {
720                unimplemented!()
721            }
722
723            async fn get_crate_data(&self, crate_name: &NormalizedName) -> DbResult<CrateData> {
724                unimplemented!()
725            }
726
727            async fn add_empty_crate(&self, name: &str, created: &DateTime<Utc>) -> DbResult<i64> {
728                unimplemented!()
729            }
730
731            async fn add_crate(&self, pub_metadata: &PublishMetadata, sha256: &str, created: &DateTime<Utc>, owner: &str) -> DbResult<i64> {
732                unimplemented!()
733            }
734
735            async fn update_docs_link(&self, crate_name: &NormalizedName, version: &Version, docs_link: &str) -> DbResult<()> {
736                unimplemented!()
737            }
738
739            async fn add_crate_metadata(&self, pub_metadata: &PublishMetadata, created: &str, crate_id: i64,) -> DbResult<()> {
740                unimplemented!()
741            }
742
743            async fn get_prefetch_data(&self, crate_name: &str) -> DbResult<Prefetch> {
744                unimplemented!()
745            }
746
747            async fn is_cratesio_cache_up_to_date(&self, crate_name: &NormalizedName, etag: Option<String>, last_modified: Option<String>) -> DbResult<PrefetchState> {
748                unimplemented!()
749            }
750
751            async fn add_cratesio_prefetch_data(
752                &self,
753                crate_name: &OriginalName,
754                etag: &str,
755                last_modified: &str,
756                description: Option<String>,
757                indices: &[IndexMetadata],
758            ) -> DbResult<Prefetch> {
759                unimplemented!()
760            }
761
762            async fn get_cratesio_index_update_list(&self) -> DbResult<Vec<CratesioPrefetchMsg>> {
763                unimplemented!()
764            }
765
766            async fn get_cratesio_cksum(&self, crate_name: &NormalizedName, version: &Version) -> DbResult<Option<String>> {
767                unimplemented!()
768            }
769
770            async fn unyank_crate(&self, crate_name: &NormalizedName, version: &Version) -> DbResult<()> {
771                unimplemented!()
772            }
773
774            async fn yank_crate(&self, crate_name: &NormalizedName, version: &Version) -> DbResult<()> {
775                unimplemented!()
776            }
777
778            async fn add_group(&self, name: &str) -> DbResult<()> {
779                        unimplemented!()
780            }
781            async fn get_group(&self, name: &str) -> DbResult<Group>{
782                        unimplemented!()
783            }
784            async fn get_groups(&self) -> DbResult<Vec<Group>>{
785                        unimplemented!()
786            }
787            async fn delete_group(&self, name: &str) -> DbResult<()>{
788                        unimplemented!()
789            }
790            async fn add_group_user(&self, group_name: &str, user: &str) -> DbResult<()>{
791                        unimplemented!()
792            }
793            async fn delete_group_user(&self, group_name: &str, user: &str) -> DbResult<()>{
794                        unimplemented!()
795            }
796            async fn get_group_users(&self, group_name: &str) -> DbResult<Vec<User>> {
797                unimplemented!()
798            }
799            async fn is_group_user(&self, group_name: &str, user: &str) -> DbResult<bool> {
800                unimplemented!()
801            }
802
803            async fn add_crate_group(&self, crate_name: &NormalizedName, group: &str) -> DbResult<()>{
804                unimplemented!()
805            }
806            async fn delete_crate_group(&self, crate_name: &NormalizedName, group: &str) -> DbResult<()>{
807                unimplemented!()
808            }
809            async fn get_crate_groups(&self, crate_name: &NormalizedName) -> DbResult<Vec<Group>>{
810                unimplemented!()
811            }
812            async fn is_crate_group(&self, crate_name: &NormalizedName, group: &str) -> DbResult<bool>{
813                unimplemented!()
814            }
815
816            async fn is_crate_group_user(&self, crate_name: &NormalizedName, user: &str) -> DbResult<bool>{
817                unimplemented!()
818            }
819
820            async fn register_webhook(
821                &self,
822                webhook: Webhook
823            ) -> DbResult<String> {
824                unimplemented!()
825            }
826            async fn delete_webhook(&self, id: &str) -> DbResult<()> {
827                unimplemented!()
828            }
829            async fn get_webhook(&self, id: &str) -> DbResult<Webhook> {
830                unimplemented!()
831            }
832            async fn get_all_webhooks(&self) -> DbResult<Vec<Webhook>> {
833                unimplemented!()
834            }
835            async fn add_webhook_queue(&self, event: WebhookEvent, payload: serde_json::Value) -> DbResult<()> {
836                unimplemented!()
837            }
838            async fn get_pending_webhook_queue_entries(&self, timestamp: DateTime<Utc>) -> DbResult<Vec<WebhookQueue>> {
839                unimplemented!()
840            }
841            async fn update_webhook_queue(&self, id: &str, last_attempt: DateTime<Utc>, next_attempt: DateTime<Utc>) -> DbResult<()> {
842                unimplemented!()
843            }
844            async fn delete_webhook_queue(&self, id: &str) -> DbResult<()> {
845                unimplemented!()
846            }
847
848            async fn get_user_by_oauth2_identity(
849                &self,
850                issuer: &str,
851                subject: &str,
852            ) -> DbResult<Option<User>> {
853                unimplemented!()
854            }
855
856            async fn has_oauth2_admin(&self) -> DbResult<bool> {
857                unimplemented!()
858            }
859
860            async fn create_oauth2_user(
861                &self,
862                username: &str,
863                issuer: &str,
864                subject: &str,
865                email: Option<String>,
866                is_admin: bool,
867                is_read_only: bool,
868            ) -> DbResult<User> {
869                unimplemented!()
870            }
871
872            async fn link_oauth2_identity(
873                &self,
874                user_id: i64,
875                issuer: &str,
876                subject: &str,
877                email: Option<String>,
878            ) -> DbResult<()> {
879                unimplemented!()
880            }
881
882            async fn store_oauth2_state(
883                &self,
884                state: &str,
885                pkce_verifier: &str,
886                nonce: &str,
887            ) -> DbResult<()> {
888                unimplemented!()
889            }
890
891            async fn get_and_delete_oauth2_state(
892                &self,
893                state: &str,
894            ) -> DbResult<Option<OAuth2StateData>> {
895                unimplemented!()
896            }
897
898            async fn cleanup_expired_oauth2_states(&self) -> DbResult<u64> {
899                unimplemented!()
900            }
901
902            async fn is_username_available(&self, username: &str) -> DbResult<bool> {
903                unimplemented!()
904            }
905
906            async fn add_toolchain(
907                &self,
908                name: &str,
909                version: &str,
910                date: &str,
911                channel: Option<String>,
912            ) -> DbResult<i64> {
913                unimplemented!()
914            }
915
916            async fn add_toolchain_target(
917                &self,
918                toolchain_id: i64,
919                target: &str,
920                storage_path: &str,
921                hash: &str,
922                size: i64,
923            ) -> DbResult<i64> {
924                unimplemented!()
925            }
926
927            async fn add_toolchain_component(
928                &self,
929                target_id: i64,
930                name: &str,
931                storage_path: &str,
932                hash: &str,
933                size: i64,
934            ) -> DbResult<()> {
935                unimplemented!()
936            }
937
938            async fn set_target_status(&self, target_id: i64, status: &str) -> DbResult<()> {
939                unimplemented!()
940            }
941
942            async fn get_toolchain_by_channel(&self, channel: &str) -> DbResult<Option<ToolchainWithTargets>> {
943                unimplemented!()
944            }
945
946            async fn get_toolchain_by_version(
947                &self,
948                name: &str,
949                version: &str,
950            ) -> DbResult<Option<ToolchainWithTargets>> {
951                unimplemented!()
952            }
953
954            async fn list_toolchains(&self) -> DbResult<Vec<ToolchainWithTargets>> {
955                unimplemented!()
956            }
957
958            async fn delete_toolchain(&self, name: &str, version: &str) -> DbResult<()> {
959                unimplemented!()
960            }
961
962            async fn delete_toolchain_target(
963                &self,
964                name: &str,
965                version: &str,
966                target: &str,
967            ) -> DbResult<()> {
968                unimplemented!()
969            }
970
971            async fn set_channel(&self, channel: &str, name: &str, version: &str) -> DbResult<()> {
972                unimplemented!()
973            }
974
975            async fn get_channels(&self) -> DbResult<Vec<ChannelInfo>> {
976                unimplemented!()
977            }
978        }
979    }
980}