SyncPostgresUriRegister

Struct SyncPostgresUriRegister 

Source
pub struct SyncPostgresUriRegister { /* private fields */ }
Expand description

Synchronous PostgreSQL URI register

This is a synchronous wrapper around PostgresUriRegister for use in synchronous Rust applications. It uses a lightweight current-thread Tokio runtime internally to execute async operations.

All methods have the same semantics as their async counterparts but block the calling thread until completion.

§Example

use uri_register::SyncPostgresUriRegister;

fn main() -> uri_register::Result<()> {
    let register = SyncPostgresUriRegister::new(
        "postgres://localhost/mydb",
        "uri_register",
        20,
        10_000
    )?;

    let id = register.register_uri("https://example.com")?;
    println!("URI registered with ID: {}", id);

    Ok(())
}

Implementations§

Source§

impl SyncPostgresUriRegister

Source

pub fn new( database_url: &str, table_name: &str, max_connections: u32, cache_size: usize, ) -> Result<Self>

Create a new synchronous PostgreSQL URI register with default cache (Moka/W-TinyLFU)

This is the backwards-compatible constructor that uses Moka caching by default.

§Arguments
  • database_url - PostgreSQL connection string
  • table_name - Name of the database table
  • max_connections - Maximum number of connections in the pool
  • cache_size - Number of URI-to-ID mappings to cache
Source

pub fn new_with_cache_strategy( database_url: &str, table_name: &str, max_connections: u32, cache_size: usize, cache_strategy: Option<CacheStrategy>, use_tls: Option<bool>, ) -> Result<Self>

Create a new synchronous PostgreSQL URI register with custom cache strategy and TLS

§Arguments
  • database_url - PostgreSQL connection string
  • table_name - Name of the database table
  • max_connections - Maximum number of connections in the pool
  • cache_size - Number of URI-to-ID mappings to cache
  • cache_strategy - Optional cache strategy (defaults to Moka if None)
  • use_tls - Optional TLS flag (defaults to false/None for backwards compatibility)
Source

pub fn register_uri(&self, uri: &str) -> Result<u64>

Register a single URI and return its ID (blocking)

If the URI already exists, returns the existing ID. If the URI is new, creates a new ID and returns it.

Source

pub fn register_uri_batch(&self, uris: &[String]) -> Result<Vec<u64>>

Register multiple URIs in batch and return their IDs (blocking)

The returned vector maintains order correspondence with the input.

Source

pub fn register_uri_batch_hashmap( &self, uris: &[String], ) -> Result<HashMap<String, u64>>

Register multiple URIs in batch and return a HashMap (blocking)

Source

pub fn stats(&self) -> Result<RegisterStats>

Get statistics about the register (blocking)

Trait Implementations§

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more