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    UpToDate,
26    NeedsUpdate(Prefetch),
27    NotFound,
28}
29
30/// Data stored during `OAuth2` authentication flow for CSRF/PKCE verification
31#[derive(Debug, Clone, PartialEq, Eq)]
32pub struct OAuth2StateData {
33    pub state: String,
34    pub pkce_verifier: String,
35    pub nonce: String,
36}
37
38/// Toolchain target information (e.g., a specific archive for a target triple)
39#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, utoipa::ToSchema)]
40pub struct ToolchainTargetInfo {
41    /// Target ID
42    pub id: i64,
43    /// Target triple (e.g., "x86_64-unknown-linux-gnu")
44    pub target: String,
45    /// Path to the stored archive
46    pub storage_path: String,
47    /// SHA256 hash of the archive
48    pub hash: String,
49    /// Archive size in bytes
50    pub size: i64,
51}
52
53impl From<kellnr_entity::toolchain_target::Model> for ToolchainTargetInfo {
54    fn from(t: kellnr_entity::toolchain_target::Model) -> Self {
55        Self {
56            id: t.id,
57            target: t.target,
58            storage_path: t.storage_path,
59            hash: t.hash,
60            size: t.size,
61        }
62    }
63}
64
65/// Toolchain with all its targets
66#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, utoipa::ToSchema)]
67pub struct ToolchainWithTargets {
68    /// Toolchain ID
69    pub id: i64,
70    /// Toolchain name (e.g., "rust")
71    pub name: String,
72    /// Toolchain version (e.g., "1.75.0")
73    pub version: String,
74    /// Release date
75    pub date: String,
76    /// Channel (e.g., "stable", "beta", "nightly")
77    pub channel: Option<String>,
78    /// Creation timestamp
79    pub created: String,
80    /// Available targets for this toolchain
81    pub targets: Vec<ToolchainTargetInfo>,
82}
83
84impl ToolchainWithTargets {
85    /// Build from toolchain entity model and its target models.
86    pub fn from_model(
87        tc: kellnr_entity::toolchain::Model,
88        targets: Vec<kellnr_entity::toolchain_target::Model>,
89    ) -> Self {
90        Self {
91            id: tc.id,
92            name: tc.name,
93            version: tc.version,
94            date: tc.date,
95            channel: tc.channel,
96            created: tc.created,
97            targets: targets.into_iter().map(ToolchainTargetInfo::from).collect(),
98        }
99    }
100}
101
102/// Channel information (e.g., "stable" -> "1.75.0")
103#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, utoipa::ToSchema)]
104pub struct ChannelInfo {
105    /// Channel name (e.g., "stable", "beta", "nightly")
106    pub name: String,
107    /// Toolchain version pointed to by this channel
108    pub version: String,
109    /// Release date
110    pub date: String,
111}
112
113#[async_trait]
114pub trait DbProvider: Send + Sync {
115    async fn get_last_updated_crate(&self) -> DbResult<Option<(OriginalName, Version)>>;
116    async fn authenticate_user(&self, name: &str, pwd: &str) -> DbResult<User>;
117    async fn increase_download_counter(
118        &self,
119        crate_name: &NormalizedName,
120        crate_version: &Version,
121    ) -> DbResult<()>;
122    async fn increase_cached_download_counter(
123        &self,
124        crate_name: &NormalizedName,
125        crate_version: &Version,
126    ) -> DbResult<()>;
127    async fn validate_session(&self, session_token: &str) -> DbResult<(String, bool)>;
128    async fn add_session_token(&self, name: &str, session_token: &str) -> DbResult<()>;
129    async fn add_crate_user(&self, crate_name: &NormalizedName, user: &str) -> DbResult<()>;
130    async fn add_owner(&self, crate_name: &NormalizedName, owner: &str) -> DbResult<()>;
131    async fn is_download_restricted(&self, crate_name: &NormalizedName) -> DbResult<bool>;
132    async fn change_download_restricted(
133        &self,
134        crate_name: &NormalizedName,
135        restricted: bool,
136    ) -> DbResult<()>;
137    async fn is_crate_user(&self, crate_name: &NormalizedName, user: &str) -> DbResult<bool>;
138    async fn is_owner(&self, crate_name: &NormalizedName, user: &str) -> DbResult<bool>;
139    async fn get_crate_id(&self, crate_name: &NormalizedName) -> DbResult<Option<i64>>;
140    async fn get_crate_owners(&self, crate_name: &NormalizedName) -> DbResult<Vec<User>>;
141    async fn get_crate_users(&self, crate_name: &NormalizedName) -> DbResult<Vec<User>>;
142    async fn get_crate_versions(&self, crate_name: &NormalizedName) -> DbResult<Vec<Version>>;
143    async fn delete_session_token(&self, session_token: &str) -> DbResult<()>;
144    async fn delete_user(&self, user_name: &str) -> DbResult<()>;
145    async fn change_pwd(&self, user_name: &str, new_pwd: &str) -> DbResult<()>;
146    async fn change_read_only_state(&self, user_name: &str, state: bool) -> DbResult<()>;
147    async fn change_admin_state(&self, user_name: &str, state: bool) -> DbResult<()>;
148    async fn crate_version_exists(&self, crate_id: i64, version: &str) -> DbResult<bool>;
149    async fn get_max_version_from_id(&self, crate_id: i64) -> DbResult<Version>;
150    async fn get_max_version_from_name(&self, crate_name: &NormalizedName) -> DbResult<Version>;
151    async fn update_max_version(&self, crate_id: i64, version: &Version) -> DbResult<()>;
152    async fn add_auth_token(&self, name: &str, token: &str, user: &str) -> DbResult<()>;
153    async fn get_user_from_token(&self, token: &str) -> DbResult<User>;
154    async fn get_user(&self, name: &str) -> DbResult<User>;
155    async fn get_auth_tokens(&self, user_name: &str) -> DbResult<Vec<AuthToken>>;
156    async fn delete_auth_token(&self, id: i32) -> DbResult<()>;
157    async fn delete_owner(&self, crate_name: &str, owner: &str) -> DbResult<()>;
158    async fn delete_crate_user(&self, crate_name: &NormalizedName, user: &str) -> DbResult<()>;
159    async fn add_user(
160        &self,
161        name: &str,
162        pwd: &str,
163        salt: &str,
164        is_admin: bool,
165        is_read_only: bool,
166    ) -> DbResult<()>;
167    async fn get_users(&self) -> DbResult<Vec<User>>;
168    async fn add_group(&self, name: &str) -> DbResult<()>;
169    async fn get_group(&self, name: &str) -> DbResult<Group>;
170    async fn get_groups(&self) -> DbResult<Vec<Group>>;
171    async fn delete_group(&self, name: &str) -> DbResult<()>;
172    async fn add_group_user(&self, group_name: &str, user: &str) -> DbResult<()>;
173    async fn delete_group_user(&self, group_name: &str, user: &str) -> DbResult<()>;
174    async fn get_group_users(&self, group_name: &str) -> DbResult<Vec<User>>;
175    async fn is_group_user(&self, group_name: &str, group: &str) -> DbResult<bool>;
176    async fn add_crate_group(&self, crate_name: &NormalizedName, group: &str) -> DbResult<()>;
177    async fn delete_crate_group(&self, crate_name: &NormalizedName, group: &str) -> DbResult<()>;
178    async fn get_crate_groups(&self, crate_name: &NormalizedName) -> DbResult<Vec<Group>>;
179    async fn is_crate_group(&self, crate_name: &NormalizedName, group: &str) -> DbResult<bool>;
180    async fn is_crate_group_user(&self, crate_name: &NormalizedName, user: &str) -> DbResult<bool>;
181    async fn get_total_unique_crates(&self) -> DbResult<u64>;
182    async fn get_total_crate_versions(&self) -> DbResult<u64>;
183    async fn get_total_downloads(&self) -> DbResult<u64>;
184    async fn get_top_crates_downloads(&self, top: u64) -> DbResult<Vec<(String, u64)>>;
185    async fn get_total_unique_cached_crates(&self) -> DbResult<u64>;
186    async fn get_total_cached_crate_versions(&self) -> DbResult<u64>;
187    async fn get_total_cached_downloads(&self) -> DbResult<u64>;
188    async fn get_crate_summaries(&self) -> DbResult<Vec<CrateSummary>>;
189    async fn add_doc_queue(
190        &self,
191        krate: &NormalizedName,
192        version: &Version,
193        path: &Path,
194    ) -> DbResult<()>;
195    async fn delete_doc_queue(&self, id: i64) -> DbResult<()>;
196    async fn get_doc_queue(&self) -> DbResult<Vec<DocQueueEntry>>;
197    async fn delete_crate(&self, krate: &NormalizedName, version: &Version) -> DbResult<()>;
198    async fn get_crate_meta_list(&self, crate_name: &NormalizedName) -> DbResult<Vec<CrateMeta>>;
199    async fn update_last_updated(&self, id: i64, last_updated: &DateTime<Utc>) -> DbResult<()>;
200    async fn search_in_crate_name(
201        &self,
202        contains: &str,
203        cache: bool,
204    ) -> DbResult<Vec<CrateOverview>>;
205    async fn get_crate_overview_list(
206        &self,
207        limit: u64,
208        offset: u64,
209        cache: bool,
210    ) -> DbResult<Vec<CrateOverview>>;
211    async fn get_crate_data(&self, crate_name: &NormalizedName) -> DbResult<CrateData>;
212    async fn add_empty_crate(&self, name: &str, created: &DateTime<Utc>) -> DbResult<i64>;
213    async fn add_crate(
214        &self,
215        pub_metadata: &PublishMetadata,
216        cksum: &str,
217        created: &DateTime<Utc>,
218        owner: &str,
219    ) -> DbResult<i64>;
220    async fn update_docs_link(
221        &self,
222        crate_name: &NormalizedName,
223        version: &Version,
224        docs_link: &str,
225    ) -> DbResult<()>;
226    async fn add_crate_metadata(
227        &self,
228        pub_metadata: &PublishMetadata,
229        created: &str,
230        crate_id: i64,
231    ) -> DbResult<()>;
232    async fn get_prefetch_data(&self, crate_name: &str) -> DbResult<Prefetch>;
233    async fn is_cratesio_cache_up_to_date(
234        &self,
235        crate_name: &NormalizedName,
236        if_none_match: Option<String>,
237        if_modified_since: Option<String>,
238    ) -> DbResult<PrefetchState>;
239    async fn add_cratesio_prefetch_data(
240        &self,
241        crate_name: &OriginalName,
242        etag: &str,
243        last_modified: &str,
244        description: Option<String>,
245        indices: &[IndexMetadata],
246    ) -> DbResult<Prefetch>;
247    async fn get_cratesio_index_update_list(&self) -> DbResult<Vec<CratesioPrefetchMsg>>;
248    async fn unyank_crate(&self, crate_name: &NormalizedName, version: &Version) -> DbResult<()>;
249    async fn yank_crate(&self, crate_name: &NormalizedName, version: &Version) -> DbResult<()>;
250    async fn register_webhook(&self, webhook: Webhook) -> DbResult<String>;
251    async fn delete_webhook(&self, id: &str) -> DbResult<()>;
252    async fn get_webhook(&self, id: &str) -> DbResult<Webhook>;
253    async fn get_all_webhooks(&self) -> DbResult<Vec<Webhook>>;
254    /// Creates a new webhook queue entry for each register webhook
255    /// matching the given event. `Next_attempt` is set to current time,
256    ///  in order to trigger immediate dispatch.
257    async fn add_webhook_queue(
258        &self,
259        event: WebhookEvent,
260        payload: serde_json::Value,
261    ) -> DbResult<()>;
262    /// Extracts webhook queue entries with `next_attempt` at or earlier than provided timestamp.
263    async fn get_pending_webhook_queue_entries(
264        &self,
265        timestamp: DateTime<Utc>,
266    ) -> DbResult<Vec<WebhookQueue>>;
267    async fn update_webhook_queue(
268        &self,
269        id: &str,
270        last_attempt: DateTime<Utc>,
271        next_attempt: DateTime<Utc>,
272    ) -> DbResult<()>;
273    async fn delete_webhook_queue(&self, id: &str) -> DbResult<()>;
274
275    // `OAuth2` identity methods
276    /// Look up a user by their `OAuth2` identity (issuer + subject)
277    async fn get_user_by_oauth2_identity(
278        &self,
279        issuer: &str,
280        subject: &str,
281    ) -> DbResult<Option<User>>;
282
283    /// Create a new user from `OAuth2` authentication and link their identity
284    async fn create_oauth2_user(
285        &self,
286        username: &str,
287        issuer: &str,
288        subject: &str,
289        email: Option<String>,
290        is_admin: bool,
291        is_read_only: bool,
292    ) -> DbResult<User>;
293
294    /// Link an `OAuth2` identity to an existing user
295    async fn link_oauth2_identity(
296        &self,
297        user_id: i64,
298        issuer: &str,
299        subject: &str,
300        email: Option<String>,
301    ) -> DbResult<()>;
302
303    // `OAuth2` state methods (CSRF/PKCE during auth flow)
304    /// Store `OAuth2` state for CSRF/PKCE verification during auth flow
305    async fn store_oauth2_state(
306        &self,
307        state: &str,
308        pkce_verifier: &str,
309        nonce: &str,
310    ) -> DbResult<()>;
311
312    /// Retrieve and delete `OAuth2` state (single use)
313    async fn get_and_delete_oauth2_state(&self, state: &str) -> DbResult<Option<OAuth2StateData>>;
314
315    /// Clean up expired `OAuth2` states (older than 10 minutes)
316    async fn cleanup_expired_oauth2_states(&self) -> DbResult<u64>;
317
318    /// Check if username is available (for `OAuth2` auto-provisioning)
319    async fn is_username_available(&self, username: &str) -> DbResult<bool>;
320
321    // Toolchain distribution methods
322    /// Add a new toolchain release
323    async fn add_toolchain(
324        &self,
325        name: &str,
326        version: &str,
327        date: &str,
328        channel: Option<String>,
329    ) -> DbResult<i64>;
330
331    /// Add a target archive to an existing toolchain
332    async fn add_toolchain_target(
333        &self,
334        toolchain_id: i64,
335        target: &str,
336        storage_path: &str,
337        hash: &str,
338        size: i64,
339    ) -> DbResult<()>;
340
341    /// Get a toolchain by its channel (e.g., "stable", "nightly")
342    async fn get_toolchain_by_channel(
343        &self,
344        channel: &str,
345    ) -> DbResult<Option<ToolchainWithTargets>>;
346
347    /// Get a toolchain by name and version
348    async fn get_toolchain_by_version(
349        &self,
350        name: &str,
351        version: &str,
352    ) -> DbResult<Option<ToolchainWithTargets>>;
353
354    /// List all toolchains
355    async fn list_toolchains(&self) -> DbResult<Vec<ToolchainWithTargets>>;
356
357    /// Delete a toolchain and all its targets
358    async fn delete_toolchain(&self, name: &str, version: &str) -> DbResult<()>;
359
360    /// Delete a specific toolchain target
361    async fn delete_toolchain_target(
362        &self,
363        name: &str,
364        version: &str,
365        target: &str,
366    ) -> DbResult<()>;
367
368    /// Set a channel to point to a specific toolchain version
369    async fn set_channel(&self, channel: &str, name: &str, version: &str) -> DbResult<()>;
370
371    /// Get all channels with their current versions
372    async fn get_channels(&self) -> DbResult<Vec<ChannelInfo>>;
373}
374
375pub mod mock {
376    use chrono::DateTime;
377    use mockall::predicate::*;
378    use mockall::*;
379
380    use super::*;
381
382    mock! {
383          pub Db {}
384
385        #[async_trait]
386        impl DbProvider for Db {
387
388            async fn get_last_updated_crate(&self) -> DbResult<Option<(OriginalName, Version)>> {
389                unimplemented!()
390            }
391
392            async fn authenticate_user(&self, _name: &str, _pwd: &str) -> DbResult<User> {
393                unimplemented!()
394            }
395
396            async fn increase_download_counter(
397                &self,
398                _crate_name: &NormalizedName,
399                _crate_version: &Version,
400            ) -> DbResult<()> {
401                unimplemented!()
402            }
403
404            async fn increase_cached_download_counter(
405                &self,
406                _crate_name: &NormalizedName,
407                _crate_version: &Version,
408            ) -> DbResult<()> {
409                unimplemented!()
410            }
411
412            async fn validate_session(&self, _session_token: &str) -> DbResult<(String, bool)> {
413                unimplemented!()
414            }
415
416            async fn add_session_token(&self, _name: &str, _session_token: &str) -> DbResult<()> {
417                unimplemented!()
418            }
419
420            async fn add_crate_user(&self, crate_name: &NormalizedName, user: &str) -> DbResult<()> {
421                unimplemented!()
422            }
423
424            async fn add_owner(&self, _crate_name: &NormalizedName, _owner: &str) -> DbResult<()> {
425                unimplemented!()
426            }
427
428            async fn is_download_restricted(&self, crate_name: &NormalizedName) -> DbResult<bool> {
429                unimplemented!()
430            }
431
432            async fn change_download_restricted(
433                &self,
434                crate_name: &NormalizedName,
435                restricted: bool,
436            ) -> DbResult<()> {
437                unimplemented!()
438            }
439
440            async fn is_crate_user(&self, _crate_name: &NormalizedName, _user: &str) -> DbResult<bool> {
441                unimplemented!()
442            }
443
444            async fn is_owner(&self, _crate_name: &NormalizedName, _user: &str) -> DbResult<bool> {
445                unimplemented!()
446            }
447
448            async fn get_crate_id(&self, _crate_name: &NormalizedName) -> DbResult<Option<i64>> {
449                unimplemented!()
450            }
451
452            async fn get_crate_owners(&self, _crate_name: &NormalizedName) -> DbResult<Vec<User>> {
453                unimplemented!()
454            }
455
456            async fn get_crate_users(&self, _crate_name: &NormalizedName) -> DbResult<Vec<User>> {
457                unimplemented!()
458            }
459
460            async fn get_crate_versions(&self, _crate_name: &NormalizedName) -> DbResult<Vec<Version>> {
461                unimplemented!()
462            }
463
464            async fn delete_session_token(&self, _session_token: &str) -> DbResult<()> {
465                unimplemented!()
466            }
467
468            async fn delete_user(&self, _user_name: &str) -> DbResult<()> {
469                unimplemented!()
470            }
471
472            async fn change_pwd(&self, _user_name: &str, _new_pwd: &str) -> DbResult<()> {
473                unimplemented!()
474            }
475
476            async fn change_read_only_state(&self, _user_name: &str, _state: bool) -> DbResult<()> {
477                unimplemented!()
478            }
479
480            async fn change_admin_state(&self, _user_name: &str, _state: bool) -> DbResult<()> {
481                unimplemented!()
482            }
483
484            async fn crate_version_exists(&self, _crate_id: i64, _version: &str) -> DbResult<bool> {
485                unimplemented!()
486            }
487
488            async fn get_max_version_from_id(&self, crate_id: i64) -> DbResult<Version>  {
489                unimplemented!()
490            }
491
492            async fn get_max_version_from_name(&self, crate_name: &NormalizedName) -> DbResult<Version> {
493                unimplemented!()
494            }
495
496            async fn update_max_version(&self, crate_id: i64, version: &Version) -> DbResult<()> {
497                unimplemented!()
498            }
499
500            async fn add_auth_token(&self, _name: &str, _token: &str, _user: &str) -> DbResult<()> {
501                unimplemented!()
502            }
503
504            async fn get_user_from_token(&self, _token: &str) -> DbResult<User> {
505                unimplemented!()
506            }
507
508            async fn get_user(&self, _name: &str) -> DbResult<User> {
509                unimplemented!()
510            }
511
512            async fn get_auth_tokens(&self, _user_name: &str) -> DbResult<Vec<AuthToken>> {
513                unimplemented!()
514            }
515
516            async fn delete_auth_token(&self, _id: i32) -> DbResult<()> {
517                unimplemented!()
518            }
519
520            async fn delete_owner(&self, _crate_name: &str, _owner: &str) -> DbResult<()> {
521                unimplemented!()
522            }
523
524            async fn delete_crate_user(&self, crate_name: &NormalizedName, user: &str) -> DbResult<()>{
525                unimplemented!()
526            }
527
528            async fn add_user(&self, _name: &str, _pwd: &str, _salt: &str, _is_admin: bool, _is_read_only: bool) -> DbResult<()> {
529                unimplemented!()
530            }
531
532            async fn get_users(&self) -> DbResult<Vec<User>> {
533                unimplemented!()
534            }
535
536            async fn get_total_unique_crates(&self) -> DbResult<u64> {
537                unimplemented!()
538            }
539
540            async fn get_total_crate_versions(&self) -> DbResult<u64> {
541                unimplemented!()
542            }
543
544            async fn get_top_crates_downloads(&self, _top: u64) -> DbResult<Vec<(String, u64)>> {
545                unimplemented!()
546            }
547
548            async fn get_total_unique_cached_crates(&self) -> DbResult<u64> {
549                unimplemented!()
550            }
551
552            async fn get_total_cached_crate_versions(&self) -> DbResult<u64> {
553                unimplemented!()
554            }
555
556            async fn get_total_cached_downloads(&self) -> DbResult<u64> {
557                unimplemented!()
558            }
559
560            async fn get_crate_summaries(&self) -> DbResult<Vec<CrateSummary >> {
561                unimplemented!()
562            }
563
564                async fn add_doc_queue(&self, krate: &NormalizedName, version: &Version, path: &Path) -> DbResult<()>{
565                    unimplemented!()
566                }
567
568            async fn delete_doc_queue(&self, id: i64) -> DbResult<()>{
569                    unimplemented!()
570                }
571
572            async fn get_doc_queue(&self) -> DbResult<Vec<DocQueueEntry>> {
573                unimplemented!()
574            }
575
576            async fn delete_crate(&self, krate: &NormalizedName, version: &Version) -> DbResult<()> {
577                unimplemented!()
578            }
579
580            async fn get_total_downloads(&self) -> DbResult<u64>{
581                unimplemented!()
582            }
583
584            async fn get_crate_meta_list(&self, crate_name: &NormalizedName) -> DbResult<Vec<CrateMeta>>{
585                unimplemented!()
586            }
587
588            async fn update_last_updated(&self, id: i64, last_updated: &DateTime<Utc>) -> DbResult<()>{
589                unimplemented!()
590            }
591
592            async fn search_in_crate_name(&self, contains: &str, cache: bool) -> DbResult<Vec<CrateOverview>> {
593                unimplemented!()
594            }
595
596            async fn get_crate_overview_list(&self, limit: u64, offset: u64, cache: bool) -> DbResult<Vec<CrateOverview >> {
597                unimplemented!()
598            }
599
600            async fn get_crate_data(&self, crate_name: &NormalizedName) -> DbResult<CrateData> {
601                unimplemented!()
602            }
603
604            async fn add_empty_crate(&self, name: &str, created: &DateTime<Utc>) -> DbResult<i64> {
605                unimplemented!()
606            }
607
608            async fn add_crate(&self, pub_metadata: &PublishMetadata, sha256: &str, created: &DateTime<Utc>, owner: &str) -> DbResult<i64> {
609                unimplemented!()
610            }
611
612            async fn update_docs_link(&self, crate_name: &NormalizedName, version: &Version, docs_link: &str) -> DbResult<()> {
613                unimplemented!()
614            }
615
616            async fn add_crate_metadata(&self, pub_metadata: &PublishMetadata, created: &str, crate_id: i64,) -> DbResult<()> {
617                unimplemented!()
618            }
619
620            async fn get_prefetch_data(&self, crate_name: &str) -> DbResult<Prefetch> {
621                unimplemented!()
622            }
623
624            async fn is_cratesio_cache_up_to_date(&self, crate_name: &NormalizedName, etag: Option<String>, last_modified: Option<String>) -> DbResult<PrefetchState> {
625                unimplemented!()
626            }
627
628            async fn add_cratesio_prefetch_data(
629                &self,
630                crate_name: &OriginalName,
631                etag: &str,
632                last_modified: &str,
633                description: Option<String>,
634                indices: &[IndexMetadata],
635            ) -> DbResult<Prefetch> {
636                unimplemented!()
637            }
638
639            async fn get_cratesio_index_update_list(&self) -> DbResult<Vec<CratesioPrefetchMsg>> {
640                unimplemented!()
641            }
642
643            async fn unyank_crate(&self, crate_name: &NormalizedName, version: &Version) -> DbResult<()> {
644                unimplemented!()
645            }
646
647            async fn yank_crate(&self, crate_name: &NormalizedName, version: &Version) -> DbResult<()> {
648                unimplemented!()
649            }
650
651            async fn add_group(&self, name: &str) -> DbResult<()> {
652                        unimplemented!()
653            }
654            async fn get_group(&self, name: &str) -> DbResult<Group>{
655                        unimplemented!()
656            }
657            async fn get_groups(&self) -> DbResult<Vec<Group>>{
658                        unimplemented!()
659            }
660            async fn delete_group(&self, name: &str) -> DbResult<()>{
661                        unimplemented!()
662            }
663            async fn add_group_user(&self, group_name: &str, user: &str) -> DbResult<()>{
664                        unimplemented!()
665            }
666            async fn delete_group_user(&self, group_name: &str, user: &str) -> DbResult<()>{
667                        unimplemented!()
668            }
669            async fn get_group_users(&self, group_name: &str) -> DbResult<Vec<User>> {
670                unimplemented!()
671            }
672            async fn is_group_user(&self, group_name: &str, user: &str) -> DbResult<bool> {
673                unimplemented!()
674            }
675
676            async fn add_crate_group(&self, crate_name: &NormalizedName, group: &str) -> DbResult<()>{
677                unimplemented!()
678            }
679            async fn delete_crate_group(&self, crate_name: &NormalizedName, group: &str) -> DbResult<()>{
680                unimplemented!()
681            }
682            async fn get_crate_groups(&self, crate_name: &NormalizedName) -> DbResult<Vec<Group>>{
683                unimplemented!()
684            }
685            async fn is_crate_group(&self, crate_name: &NormalizedName, group: &str) -> DbResult<bool>{
686                unimplemented!()
687            }
688
689            async fn is_crate_group_user(&self, crate_name: &NormalizedName, user: &str) -> DbResult<bool>{
690                unimplemented!()
691            }
692
693            async fn register_webhook(
694                &self,
695                webhook: Webhook
696            ) -> DbResult<String> {
697                unimplemented!()
698            }
699            async fn delete_webhook(&self, id: &str) -> DbResult<()> {
700                unimplemented!()
701            }
702            async fn get_webhook(&self, id: &str) -> DbResult<Webhook> {
703                unimplemented!()
704            }
705            async fn get_all_webhooks(&self) -> DbResult<Vec<Webhook>> {
706                unimplemented!()
707            }
708            async fn add_webhook_queue(&self, event: WebhookEvent, payload: serde_json::Value) -> DbResult<()> {
709                unimplemented!()
710            }
711            async fn get_pending_webhook_queue_entries(&self, timestamp: DateTime<Utc>) -> DbResult<Vec<WebhookQueue>> {
712                unimplemented!()
713            }
714            async fn update_webhook_queue(&self, id: &str, last_attempt: DateTime<Utc>, next_attempt: DateTime<Utc>) -> DbResult<()> {
715                unimplemented!()
716            }
717            async fn delete_webhook_queue(&self, id: &str) -> DbResult<()> {
718                unimplemented!()
719            }
720
721            async fn get_user_by_oauth2_identity(
722                &self,
723                issuer: &str,
724                subject: &str,
725            ) -> DbResult<Option<User>> {
726                unimplemented!()
727            }
728
729            async fn create_oauth2_user(
730                &self,
731                username: &str,
732                issuer: &str,
733                subject: &str,
734                email: Option<String>,
735                is_admin: bool,
736                is_read_only: bool,
737            ) -> DbResult<User> {
738                unimplemented!()
739            }
740
741            async fn link_oauth2_identity(
742                &self,
743                user_id: i64,
744                issuer: &str,
745                subject: &str,
746                email: Option<String>,
747            ) -> DbResult<()> {
748                unimplemented!()
749            }
750
751            async fn store_oauth2_state(
752                &self,
753                state: &str,
754                pkce_verifier: &str,
755                nonce: &str,
756            ) -> DbResult<()> {
757                unimplemented!()
758            }
759
760            async fn get_and_delete_oauth2_state(
761                &self,
762                state: &str,
763            ) -> DbResult<Option<OAuth2StateData>> {
764                unimplemented!()
765            }
766
767            async fn cleanup_expired_oauth2_states(&self) -> DbResult<u64> {
768                unimplemented!()
769            }
770
771            async fn is_username_available(&self, username: &str) -> DbResult<bool> {
772                unimplemented!()
773            }
774
775            async fn add_toolchain(
776                &self,
777                name: &str,
778                version: &str,
779                date: &str,
780                channel: Option<String>,
781            ) -> DbResult<i64> {
782                unimplemented!()
783            }
784
785            async fn add_toolchain_target(
786                &self,
787                toolchain_id: i64,
788                target: &str,
789                storage_path: &str,
790                hash: &str,
791                size: i64,
792            ) -> DbResult<()> {
793                unimplemented!()
794            }
795
796            async fn get_toolchain_by_channel(&self, channel: &str) -> DbResult<Option<ToolchainWithTargets>> {
797                unimplemented!()
798            }
799
800            async fn get_toolchain_by_version(
801                &self,
802                name: &str,
803                version: &str,
804            ) -> DbResult<Option<ToolchainWithTargets>> {
805                unimplemented!()
806            }
807
808            async fn list_toolchains(&self) -> DbResult<Vec<ToolchainWithTargets>> {
809                unimplemented!()
810            }
811
812            async fn delete_toolchain(&self, name: &str, version: &str) -> DbResult<()> {
813                unimplemented!()
814            }
815
816            async fn delete_toolchain_target(
817                &self,
818                name: &str,
819                version: &str,
820                target: &str,
821            ) -> DbResult<()> {
822                unimplemented!()
823            }
824
825            async fn set_channel(&self, channel: &str, name: &str, version: &str) -> DbResult<()> {
826                unimplemented!()
827            }
828
829            async fn get_channels(&self) -> DbResult<Vec<ChannelInfo>> {
830                unimplemented!()
831            }
832        }
833    }
834}