pub fn fingerprint(statement: &str) -> Result<Fingerprint> {
    let input = CString::new(statement)?;
    let result = unsafe { pg_query_fingerprint(input.as_ptr()) };
    let fingerprint = if !result.error.is_null() {
        let message = unsafe { CStr::from_ptr((*result.error).message) }.to_string_lossy().to_string();
        Err(Error::Parse(message))
    } else {
        let hex = unsafe { CStr::from_ptr(result.fingerprint_str) };
        Ok(Fingerprint { value: result.fingerprint, hex: hex.to_string_lossy().to_string() })
    };
    unsafe { pg_query_free_fingerprint_result(result) };
    fingerprint
}
/// Fingerprints the given SQL statement. Useful for comparing parse trees across different implementations
/// of `libpg_query`.
///
/// # Example
///
/// ```rust
/// let result = pg_query::fingerprint("SELECT * FROM contacts WHERE name='Paul'");
/// assert!(result.is_ok());
/// let result = result.unwrap();
/// assert_eq!(result.hex, "0e2581a461ece536");
/// ```
Fingerprints the given SQL statement. Useful for comparing parse trees across different implementations
of `libpg_query`.
Fingerprints the given SQL statement . Useful for comparing parse trees across different implementations of ` libpg_query ` .
pub fn fingerprint(statement: &str) -> Result<Fingerprint> {
    let input = CString::new(statement)?;
    let result = unsafe { pg_query_fingerprint(input.as_ptr()) };
    let fingerprint = if !result.error.is_null() {
        let message = unsafe { CStr::from_ptr((*result.error).message) }.to_string_lossy().to_string();
        Err(Error::Parse(message))
    } else {
        let hex = unsafe { CStr::from_ptr(result.fingerprint_str) };
        Ok(Fingerprint { value: result.fingerprint, hex: hex.to_string_lossy().to_string() })
    };
    unsafe { pg_query_free_fingerprint_result(result) };
    fingerprint
}
pub fn fingerprint ( statement : & str ) -> Result < Fingerprint > { let input = CString :: new ( statement ) ? ; let result = unsafe { pg_query_fingerprint ( input . as_ptr ( ) ) } ; let fingerprint = if ! result . error . is_null ( ) { let message = unsafe { CStr :: from_ptr ( ( * result . error ) . message ) } . to_string_lossy ( ) . to_string ( ) ; Err ( Error :: Parse ( message ) ) } else { let hex = unsafe { CStr :: from_ptr ( result . fingerprint_str ) } ; Ok ( Fingerprint { value : result . fingerprint , hex : hex . to_string_lossy ( ) . to_string ( ) } ) } ; unsafe { pg_query_free_fingerprint_result ( result ) } ; fingerprint }
Fingerprints the given SQL statement.
Fingerprints the given SQL statement .
statement
&str
statement
&str
example
```rust
let result = pg_query::fingerprint("SELECT * FROM contacts WHERE name='Paul'");
assert!(result.is_ok());
let result = result.unwrap();
assert_eq!(result.hex, "0e2581a461ece536");
```
` ` ` rust let result = pg_query :: fingerprint ( " SELECT * FROM contacts WHERE name = ' Paul ' " ) ; assert! ( result . is_ok () ) ; let result = result . unwrap () ; assert_eq! ( result . hex " 0e2581a461ece536 " ) ; ` ` `