Skip to content

Commit

Permalink
refactor: more specific imports
Browse files Browse the repository at this point in the history
Signed-off-by: vados <[email protected]>
  • Loading branch information
t3hmrman committed Jul 3, 2023
1 parent f13f9e5 commit ecbea18
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 26 deletions.
6 changes: 3 additions & 3 deletions src/cuid.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use cuid;
use pgrx::{pg_extern, pg_schema};
use pgrx::{pg_extern, error as pg_error};

/// Generate a random cuid UUID
#[pg_extern]
fn idkit_cuid_generate() -> String {
match cuid::cuid() {
Err(e) => error!("failed to generate cuid: {}", e),
Err(e) => pg_error!("failed to generate cuid: {}", e),
Ok(id) => id,
}
}
Expand All @@ -23,7 +23,7 @@ fn idkit_cuid_generate_text() -> String {
#[cfg(any(test, feature = "pg_test"))]
#[pg_schema]
mod tests {
use pgrx::pg_test;
use pgrx::{pg_schema, pg_test};

/// Basic length test
#[pg_test]
Expand Down
4 changes: 2 additions & 2 deletions src/ksuid.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pgrx::{pg_extern, pg_schema};
use ksuid::Ksuid;
use pgrx::pg_extern;

/// Generate a random KSUID (HEX-encoded)
#[pg_extern]
Expand All @@ -20,7 +20,7 @@ fn idkit_ksuid_generate_text() -> String {
#[cfg(any(test, feature = "pg_test"))]
#[pg_schema]
mod tests {
use pgrx::pg_test;
use pgrx::{pg_schema, pg_test};

/// Basic length test
#[pg_test]
Expand Down
4 changes: 2 additions & 2 deletions src/nanoid.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use pgrx::{pg_extern, pg_schema};
use pgrx::pg_extern;
use nanoid::nanoid;

/// Generate a nanoid
Expand All @@ -20,7 +20,7 @@ fn idkit_nanoid_generate_text() -> String {
#[cfg(any(test, feature = "pg_test"))]
#[pg_schema]
mod tests {
use pgrx::pg_test;
use pgrx::{pg_schema, pg_test};

#[pg_test]
/// Basic length test
Expand Down
4 changes: 2 additions & 2 deletions src/pushid.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use pgrx::{pg_extern, pg_schema};
use pgrx::pg_extern;
use pushid::PushId;
use pushid::PushIdGen;

Expand All @@ -21,7 +21,7 @@ fn idkit_pushid_generate_text() -> String {
#[cfg(any(test, feature = "pg_test"))]
#[pg_schema]
mod tests {
use pgrx::pg_test;
use pgrx::{pg_schema, pg_test};

/// Basic length test
#[pg_test]
Expand Down
6 changes: 3 additions & 3 deletions src/timeflake.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use pgx::{pg_extern, pg_schema};
use pgrx::{pg_extern, error as pg_error};
use timeflake_rs::Timeflake;

/// Generate a random timeflake UUID
Expand All @@ -7,7 +7,7 @@ fn idkit_timeflake_generate() -> String {
let generated = Timeflake::random();

if let Err(e) = generated {
error!("{}", format!("failed to generate timeflake: {}", e));
pg_error!("{}", format!("failed to generate timeflake: {}", e));
}

generated.unwrap().to_string()
Expand All @@ -26,7 +26,7 @@ fn idkit_timeflake_generate_text() -> String {
#[cfg(any(test, feature = "pg_test"))]
#[pg_schema]
mod tests {
use pgx::pg_test;
use pgrx::{pg_schema, pg_test};

/// Basic length test
#[pg_test]
Expand Down
4 changes: 2 additions & 2 deletions src/ulid.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use pgrx::{pg_extern, pg_schema};
use pgrx::pg_extern;
use ulid::Ulid;

/// Generate a ULID
Expand All @@ -20,7 +20,7 @@ fn idkit_ulid_generate_text() -> String {
#[cfg(any(test, feature = "pg_test"))]
#[pg_schema]
mod tests {
use pgrx::pg_test;
use pgrx::{pg_schema, pg_test};

/// Basic length test
#[pg_test]
Expand Down
10 changes: 5 additions & 5 deletions src/uuid_v6.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use pgrx::{pg_extern, pg_schema};
use pgrx::{error as pg_error, pg_extern};

mod vendor;
use vendor::{Node, UUIDv6};
Expand All @@ -18,13 +18,13 @@ fn idkit_uuidv6_generate_text() -> String {

/// Generate a UUID v6, producing a Postgres uuid object
#[pg_extern]
fn idkit_uuidv6_generate_uuid() -> pgx::Uuid {
fn idkit_uuidv6_generate_uuid() -> pgrx::Uuid {
let node = Node::new();

// This depends on PR to rust-uuidv6
// see: https://github.com/jedisct1/rust-uuidv6/pull/1
pgx::Uuid::from_slice(&UUIDv6::new(&node).create_bytes())
.unwrap_or_else(|e| error!("{}", format!("failed to generate/parse uuidv6: {}", e)))
pgrx::Uuid::from_slice(&UUIDv6::new(&node).create_bytes())
.unwrap_or_else(|e| pg_error!("{}", format!("failed to generate/parse uuidv6: {}", e)))
}

//////////
Expand All @@ -34,7 +34,7 @@ fn idkit_uuidv6_generate_uuid() -> pgx::Uuid {
#[cfg(any(test, feature = "pg_test"))]
#[pg_schema]
mod tests {
use pgrx::pg_test;
use pgrx::{pg_schema, pg_test};

/// Basic length test
#[pg_test]
Expand Down
10 changes: 5 additions & 5 deletions src/uuid_v7.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use pgrx::{pg_extern, pg_schema};
use pgrx::{pg_extern, error as pg_error};
use uuid7::uuid7;

/// Generate a UUID v7
Expand All @@ -15,9 +15,9 @@ fn idkit_uuidv7_generate_text() -> String {

/// Generate a UUID v7, producing a Postgres uuid object
#[pg_extern]
fn idkit_uuidv7_generate_uuid() -> pgx::Uuid {
pgx::Uuid::from_slice(uuid7().as_bytes())
.unwrap_or_else(|e| error!("{}", format!("failed to generate/parse uuidv7: {}", e)))
fn idkit_uuidv7_generate_uuid() -> pgrx::Uuid {
pgrx::Uuid::from_slice(uuid7().as_bytes())
.unwrap_or_else(|e| pg_error!("{}", format!("failed to generate/parse uuidv7: {}", e)))
}

//////////
Expand All @@ -27,7 +27,7 @@ fn idkit_uuidv7_generate_uuid() -> pgx::Uuid {
#[cfg(any(test, feature = "pg_test"))]
#[pg_schema]
mod tests {
use pgrx::pg_test;
use pgrx::{pg_schema, pg_test};

/// Basic length test
#[pg_test]
Expand Down
4 changes: 2 additions & 2 deletions src/xid.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use ::xid::new as generate_xid;
use pgrx::{pg_extern, pg_schema};
use pgrx::pg_extern;

/// Generate a random xid UUID
#[pg_extern]
Expand All @@ -20,7 +20,7 @@ fn idkit_xid_generate_text() -> String {
#[cfg(any(test, feature = "pg_test"))]
#[pg_schema]
mod tests {
use pgrx::pg_test;
use pgrx::{pg_schema, pg_test};

/// Basic length test
#[pg_test]
Expand Down

0 comments on commit ecbea18

Please sign in to comment.