Struct postgres_array::Array
source · [−]pub struct Array<T> { /* private fields */ }
Expand description
A multi-dimensional array.
Implementations
sourceimpl<T> Array<T>
impl<T> Array<T>
sourcepub fn from_parts(data: Vec<T>, dimensions: Vec<Dimension>) -> Array<T>
pub fn from_parts(data: Vec<T>, dimensions: Vec<Dimension>) -> Array<T>
Creates a new Array
from its underlying components.
The data array should be provided in the higher-dimensional equivalent of row-major order.
Panics
Panics if the number of elements provided does not match the number of elements specified by the dimensions.
sourcepub fn from_vec(data: Vec<T>, lower_bound: i32) -> Array<T>
pub fn from_vec(data: Vec<T>, lower_bound: i32) -> Array<T>
Creates a new one-dimensional array.
sourcepub fn wrap(&mut self, lower_bound: i32)
pub fn wrap(&mut self, lower_bound: i32)
Wraps this array in a new dimension of size 1.
For example, the one dimensional array [1, 2]
would turn into the
two-dimensional array [[1, 2]]
.
sourcepub fn push(&mut self, other: Array<T>)
pub fn push(&mut self, other: Array<T>)
Consumes another array, appending it to the top level dimension of this array.
The dimensions of the other array must be the same as the dimensions of this array with the first dimension removed. This includes lower bounds as well as lengths.
For example, if [3, 4]
is pushed onto [[1, 2]]
, the result is
[[1, 2], [3, 4]]
.
Panics
Panics if the dimensions of the two arrays do not match.
sourcepub fn dimensions(&self) -> &[Dimension]
pub fn dimensions(&self) -> &[Dimension]
Returns the dimensions of this array.
sourcepub fn iter(&self) -> Iter<'_, T>ⓘNotable traits for Iter<'a, T>impl<'a, T: 'a> Iterator for Iter<'a, T> type Item = &'a T;
pub fn iter(&self) -> Iter<'_, T>ⓘNotable traits for Iter<'a, T>impl<'a, T: 'a> Iterator for Iter<'a, T> type Item = &'a T;
Returns an iterator over references to the elements of the array in the higher-dimensional equivalent of row-major order.
sourcepub fn iter_mut(&mut self) -> IterMut<'_, T>ⓘNotable traits for IterMut<'a, T>impl<'a, T: 'a> Iterator for IterMut<'a, T> type Item = &'a mut T;
pub fn iter_mut(&mut self) -> IterMut<'_, T>ⓘNotable traits for IterMut<'a, T>impl<'a, T: 'a> Iterator for IterMut<'a, T> type Item = &'a mut T;
Returns an iterator over mutable references to the elements of the array in the higher-dimensional equivalent of row-major order.
sourcepub fn into_inner(self) -> Vec<T>
pub fn into_inner(self) -> Vec<T>
Returns the underlying data vector for this Array in the higher-dimensional equivalent of row-major order.
Trait Implementations
sourceimpl<'de, T> FromSql<'de> for Array<T>where
T: FromSql<'de>,
impl<'de, T> FromSql<'de> for Array<T>where
T: FromSql<'de>,
sourcefn from_sql(
ty: &Type,
raw: &'de [u8]
) -> Result<Array<T>, Box<dyn Error + Sync + Send>>
fn from_sql(
ty: &Type,
raw: &'de [u8]
) -> Result<Array<T>, Box<dyn Error + Sync + Send>>
Type
in its binary format. Read moresourcefn accepts(ty: &Type) -> bool
fn accepts(ty: &Type) -> bool
Type
. Read moresourceimpl<T, I: ArrayIndex> Index<I> for Array<T>
impl<T, I: ArrayIndex> Index<I> for Array<T>
Indexes into the Array
, retrieving a reference to the contained
value.
Since Array
s can be multi-dimensional, the Index
trait is
implemented for a variety of index types. In the most generic case, a
&[i32]
can be used. In addition, a bare i32
as well as tuples
of up to 10 i32
values may be used for convenience.
Panics
Panics if the index does not correspond to an in-bounds element of the
Array
.
Examples
let mut array = Array::from_vec(vec![0i32, 1, 2, 3], 0);
assert_eq!(2, array[2]);
array.wrap(0);
array.push(Array::from_vec(vec![4, 5, 6, 7], 0));
assert_eq!(6, array[(1, 2)]);
sourceimpl<T, I: ArrayIndex> IndexMut<I> for Array<T>
impl<T, I: ArrayIndex> IndexMut<I> for Array<T>
sourceimpl<'a, T: 'a> IntoIterator for &'a Array<T>
impl<'a, T: 'a> IntoIterator for &'a Array<T>
sourceimpl<'a, T: 'a> IntoIterator for &'a mut Array<T>
impl<'a, T: 'a> IntoIterator for &'a mut Array<T>
sourceimpl<T> IntoIterator for Array<T>
impl<T> IntoIterator for Array<T>
sourceimpl<T: PartialEq> PartialEq<Array<T>> for Array<T>
impl<T: PartialEq> PartialEq<Array<T>> for Array<T>
sourceimpl<T> ToSql for Array<T>where
T: ToSql,
impl<T> ToSql for Array<T>where
T: ToSql,
sourcefn to_sql(
&self,
ty: &Type,
w: &mut BytesMut
) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn to_sql(
&self,
ty: &Type,
w: &mut BytesMut
) -> Result<IsNull, Box<dyn Error + Sync + Send>>
self
into the binary format of the specified
Postgres Type
, appending it to out
. Read moresourcefn accepts(ty: &Type) -> bool
fn accepts(ty: &Type) -> bool
Type
. Read moresourcefn to_sql_checked(
&self,
ty: &Type,
out: &mut BytesMut
) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn to_sql_checked(
&self,
ty: &Type,
out: &mut BytesMut
) -> Result<IsNull, Box<dyn Error + Sync + Send>>
sourcefn encode_format(&self, _ty: &Type) -> Format
fn encode_format(&self, _ty: &Type) -> Format
impl<T: Eq> Eq for Array<T>
impl<T> StructuralEq for Array<T>
impl<T> StructuralPartialEq for Array<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Array<T>where
T: RefUnwindSafe,
impl<T> Send for Array<T>where
T: Send,
impl<T> Sync for Array<T>where
T: Sync,
impl<T> Unpin for Array<T>where
T: Unpin,
impl<T> UnwindSafe for Array<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<T> BorrowToSql for Twhere
T: ToSql,
impl<T> BorrowToSql for Twhere
T: ToSql,
sourcefn borrow_to_sql(&self) -> &dyn ToSql
fn borrow_to_sql(&self) -> &dyn ToSql
self
as a ToSql
trait object.