[][src]Struct pgx::stringinfo::StringInfo

pub struct StringInfo { /* fields omitted */ }

StringInfoData holds information about an extensible string that is allocated by Postgres' memory system, but generally follows Rust's drop semantics

Implementations

impl StringInfo[src]

pub fn new() -> Self[src]

Construct a new StringInfo of its default size, allocated by Postgres in CurrentMemoryContext

Unless .into_pg() or .into_char_ptr() are called, memory management of this StringInfo follow Rust's drop semantics.

pub fn with_capacity(len: usize) -> Self[src]

Construct a new StringInfo, allocated by Postgres in CurrentMemoryContext, ensuring it has a capacity of the specified len.

Note that Postgres can only represent up to 1 gigabyte of data in a StringInfo

Unless .into_pg() or .into_char_ptr() are called, memory management of this StringInfo follow Rust's drop semantics.

pub fn from_pg(sid: StringInfo) -> Option<Self>[src]

Construct a StringInfo from a Postgres-allocated pg_sys::StringInfo.

The backing pg_sys::StringInfo structure will be freed whenever the memory context in which it was originally allocated is reset.

pub fn len(&self) -> usize[src]

What is the length, excluding the trailing null byte

pub fn is_empty(&self) -> bool[src]

Do we have any characters?

pub fn push(&mut self, ch: char)[src]

Push a Rust character onto the end. A Rust char could be 4 bytes in total, so it is converted into a String first to ensure unicode correctness

pub fn push_str(&mut self, s: &str)[src]

Push a String reference onto the end

pub fn push_bytes(&mut self, bytes: &[u8])[src]

Push arbitrary bytes onto the end. Any byte sequence is allowed, include those with embedded NULLs

pub fn push_raw(&mut self, ptr: void_mut_ptr, len: usize)[src]

Push the bytes behind a raw pointer of a given length onto the end

pub fn reset(&mut self)[src]

Reset the size of the StringInfo back to zero-length. This does/// not* free any previously-allocated memory

pub fn enlarge(&mut self, needed: usize)[src]

Ensure that this StringInfo is at least needed bytes long

pub fn as_ptr(&self) -> *mut c_char[src]

A pointer representation

pub fn as_bytes(&self) -> &[u8][src]

A &[u8] byte slice representation

pub fn as_bytes_mut(&mut self) -> &mut [u8][src]

A mutable &[u8] byte slice representation

pub fn into_pg(mut self: Self) -> *mut StringInfoData[src]

Convert this StringInfo into one that is wholly owned and now managed by Postgres

pub fn into_char_ptr(mut self: Self) -> *const c_char[src]

Convert this StringInfo into a "char *" that is wholly owned and now managed by Postgres

Trait Implementations

impl Default for StringInfo[src]

impl Drop for StringInfo[src]

impl From<&'_ [u8]> for StringInfo[src]

impl From<&'_ str> for StringInfo[src]

impl From<String> for StringInfo[src]

impl From<Vec<u8, Global>> for StringInfo[src]

impl Into<&'static CStr> for StringInfo[src]

impl Into<*mut StringInfoData> for StringInfo[src]

impl ToString for StringInfo[src]

impl Write for StringInfo[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.