[−][src]Struct sibyl::Varchar
Represents Oracle character types - VARCHAR, LONG, etc.
Methods
impl<'e> Varchar<'e>
[src]
pub fn from_string(text: &str, env: &'e dyn Env) -> Result<Self>
[src]
Returns a new Varchar constructed from the specified string
Example
use sibyl as oracle; let env = oracle::env()?; let src = "Hello, World!"; let txt = oracle::Varchar::from_string(src, &env)?; assert!(13 <= txt.capacity()?); let len = txt.len(); assert_eq!(13, len); let res = unsafe { std::slice::from_raw_parts(txt.as_raw_ptr(), len as usize) }; let res = String::from_utf8_lossy(res); assert_eq!(src, res);
pub fn from_varchar(other: &'e Varchar) -> Result<Self>
[src]
Returns a new Varchar constructed with the copy of the date from the other
Varchar.
Example
use sibyl as oracle; let env = oracle::env()?; let src = "Hello, World!"; let inp = oracle::Varchar::from_string(src, &env)?; let txt = oracle::Varchar::from_varchar(&inp)?; let len = txt.len(); assert_eq!(13, len); let res = unsafe { std::slice::from_raw_parts(txt.as_raw_ptr(), len as usize) }; let res = String::from_utf8_lossy(res); assert_eq!(src, res);
pub fn with_capacity(size: usize, env: &'e dyn Env) -> Result<Self>
[src]
Returns a new Varchar with the memory allocated for the txt data.
pub fn set(&mut self, text: &str) -> Result<()>
[src]
Updates the content of self to text
Example
use sibyl as oracle; let env = oracle::env()?; let mut txt = oracle::Varchar::with_capacity(0, &env)?; let src = "Hello, World!"; txt.set(src)?; let len = txt.len(); assert_eq!(13, len); let res = unsafe { std::slice::from_raw_parts(txt.as_raw_ptr(), len as usize) }; let res = String::from_utf8_lossy(res); assert_eq!(src, res);
pub fn len(&self) -> usize
[src]
Returns the size of the string in bytes.
pub fn capacity(&self) -> Result<usize>
[src]
Returns the allocated size of string memory in bytes
pub fn resize(&mut self, new_size: usize) -> Result<()>
[src]
Changes the size of the memory of a string in the object cache. Content of the string is not preserved.
Example
use sibyl as oracle; let env = oracle::env()?; let mut txt = oracle::Varchar::with_capacity(10, &env)?; let cap = txt.capacity()?; assert!(cap >= 10); txt.resize(20); let cap = txt.capacity()?; assert!(cap >= 20); txt.resize(0); // Cannot not ask for capacity after resize to 0. // Yes, it works for OCIRaw, but not here. let res = txt.capacity(); assert!(res.is_err()); if let Err( err ) = res { assert_eq!(err, oracle::Error::Oracle((21500,"internal error code...".to_string()))); } txt.resize(16); let cap = txt.capacity()?; assert!(cap >= 16);
pub fn as_raw_ptr(&self) -> *mut u8
[src]
Returns unsafe pointer to the string data
Trait Implementations
impl<'_> ToSql for Varchar<'_>
[src]
impl<'_> ToSqlOut for Varchar<'_>
[src]
fn to_sql_output(&mut self, _col_size: usize) -> (u16, *mut c_void, usize)
[src]
fn set_len(&mut self, _new_len: usize)
[src]
Called to set the received data length (always less than the initial capacity)
impl<'_> ToString for Varchar<'_>
[src]
impl<'_> Drop for Varchar<'_>
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,