INNER CODE UNIT · Rust

new_postgres

zly2006/zhihu-plus-plus · aigc-vote-server/src/lib.rs:53

    pub async fn new_postgres(database_url: &str) -> Result<Self, ServiceError> {
        Self::new_postgres_with_credit_bypass_voters(database_url, HashSet::new()).await
    }

    pub async fn new_postgres_with_credit_bypass_voters(
        database_url: &str,
        credit_bypass_voters: HashSet<String>,
    ) -> Result<Self, ServiceError> {
        Ok(Self {
            store: Arc::new(PostgresVoteStore::connect(database_url, credit_bypass_voters).await?),
        })
    }
}

pub fn parse_credit_bypass_voters(value: &str) -> HashSet<String> {
    value
        .split(',')
        .filter_map(|item| normalize_identity_token(item))

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…