pub fn deparse(protobuf: &protobuf::ParseResult) -> Result<String> {
    let buffer = protobuf.encode_to_vec();
    let len = buffer.len() as c_uint;
    let input = unsafe { CStr::from_bytes_with_nul_unchecked(&buffer) };
    let data = input.as_ptr() as *mut c_char;
    let protobuf = PgQueryProtobuf { data: data, len: len };
    let result = unsafe { pg_query_deparse_protobuf(protobuf) };

    let deparse_result = 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 query = unsafe { CStr::from_ptr(result.query) }.to_string_lossy().to_string();
        Ok(query)
    };

    unsafe { pg_query_free_deparse_result(result) };
    deparse_result
}
/// Converts a parsed tree back into a string.
///
/// # Example
///
/// ```rust
/// use pg_query::{Node, NodeEnum, NodeRef};
///
/// let result = pg_query::parse("INSERT INTO other (name) SELECT name FROM contacts");
/// let result = result.unwrap();
/// let insert = result.protobuf.nodes()[0].0;
/// let select = result.protobuf.nodes()[1].0;
/// assert!(matches!(insert, NodeRef::InsertStmt(_)));
/// assert!(matches!(select, NodeRef::SelectStmt(_)));
///
/// // The entire parse result can be deparsed:
/// assert_eq!(result.deparse().unwrap(), "INSERT INTO other (name) SELECT name FROM contacts");
/// // Or an individual node can be deparsed:
/// assert_eq!(insert.deparse().unwrap(), "INSERT INTO other (name) SELECT name FROM contacts");
/// assert_eq!(select.deparse().unwrap(), "SELECT name FROM contacts");
/// ```
///
/// Note that this function will panic if called on a node not defined in `deparseStmt`
Converts a parsed tree back into a string.
Converts a parsed tree back into a string .
pub fn deparse(protobuf: &protobuf::ParseResult) -> Result<String> {
    let buffer = protobuf.encode_to_vec();
    let len = buffer.len() as c_uint;
    let input = unsafe { CStr::from_bytes_with_nul_unchecked(&buffer) };
    let data = input.as_ptr() as *mut c_char;
    let protobuf = PgQueryProtobuf { data: data, len: len };
    let result = unsafe { pg_query_deparse_protobuf(protobuf) };
    let deparse_result = 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 query = unsafe { CStr::from_ptr(result.query) }.to_string_lossy().to_string();
        Ok(query)
    };
    unsafe { pg_query_free_deparse_result(result) };
    deparse_result
}
pub fn deparse ( protobuf : & protobuf :: ParseResult ) -> Result < String > { let buffer = protobuf . encode_to_vec ( ) ; let len = buffer . len ( ) as c_uint ; let input = unsafe { CStr :: from_bytes_with_nul_unchecked ( & buffer ) } ; let data = input . as_ptr ( ) as * mut c_char ; let protobuf = PgQueryProtobuf { data : data , len : len } ; let result = unsafe { pg_query_deparse_protobuf ( protobuf ) } ; let deparse_result = 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 query = unsafe { CStr :: from_ptr ( result . query ) } . to_string_lossy ( ) . to_string ( ) ; Ok ( query ) } ; unsafe { pg_query_free_deparse_result ( result ) } ; deparse_result }
Converts a parsed tree back into a string.
Converts a parsed tree back into a string .
protobuf
&protobuf::ParseResult
protobuf
&protobuf::ParseResult
example
```rust
use pg_query::{Node, NodeEnum, NodeRef}.

let result = pg_query::parse("INSERT INTO other (name) SELECT name FROM contacts");
let result = result.unwrap();
let insert = result.protobuf.nodes()[0].0;
let select = result.protobuf.nodes()[1].0;
assert!(matches!(insert, NodeRef::InsertStmt(_)));
assert!(matches!(select, NodeRef::SelectStmt(_))).

The entire parse result can be deparsed:
assert_eq!(result.deparse().unwrap(), "INSERT INTO other (name) SELECT name FROM contacts");
Or an individual node can be deparsed:
assert_eq!(insert.deparse().unwrap(), "INSERT INTO other (name) SELECT name FROM contacts");
assert_eq!(select.deparse().unwrap(), "SELECT name FROM contacts");
```

Note that this function will panic if called on a node not defined in `deparseStmt`
` ` ` rust use pg_query :: { Node NodeEnum NodeRef } . let result = pg_query :: parse ( " INSERT INTO other ( name ) SELECT name FROM contacts " ) ; let result = result . unwrap () ; let insert = result . protobuf . nodes () [ 0 ] . 0 ; let select = result . protobuf . nodes () [ 1 ] . 0 ; assert! ( matches! ( insert NodeRef :: InsertStmt ( _ ))) ; assert! ( matches! ( select NodeRef :: SelectStmt ( _ ))) . The entire parse result can be deparsed : assert_eq! ( result . deparse () . unwrap () " INSERT INTO other ( name ) SELECT name FROM contacts " ) ; Or an individual node can be deparsed : assert_eq! ( insert . deparse () . unwrap () " INSERT INTO other ( name ) SELECT name FROM contacts " ) ; assert_eq! ( select . deparse () . unwrap () " SELECT name FROM contacts " ) ; ` ` ` Note that this function will panic if called on a node not defined in ` deparseStmt `