pub struct Field {
pub name: PlSmallStr,
pub dtype: DataType,
}Expand description
Characterizes the name and the DataType of a column.
Fields§
§name: PlSmallStr§dtype: DataTypeImplementations§
Source§impl Field
impl Field
Sourcepub fn new(name: PlSmallStr, dtype: DataType) -> Field
pub fn new(name: PlSmallStr, dtype: DataType) -> Field
Creates a new Field.
§Example
let f1 = Field::new("Fruit name".into(), DataType::String);
let f2 = Field::new("Lawful".into(), DataType::Boolean);
let f2 = Field::new("Departure".into(), DataType::Time);Sourcepub fn name(&self) -> &PlSmallStr
pub fn name(&self) -> &PlSmallStr
Returns a reference to the Field name.
§Example
let f = Field::new("Year".into(), DataType::Int32);
assert_eq!(f.name(), "Year");Sourcepub fn dtype(&self) -> &DataType
pub fn dtype(&self) -> &DataType
Returns a reference to the Field datatype.
§Example
let f = Field::new("Birthday".into(), DataType::Date);
assert_eq!(f.dtype(), &DataType::Date);Sourcepub fn coerce(&mut self, dtype: DataType)
pub fn coerce(&mut self, dtype: DataType)
Sets the Field datatype.
§Example
let mut f = Field::new("Temperature".into(), DataType::Int32);
f.coerce(DataType::Float32);
assert_eq!(f, Field::new("Temperature".into(), DataType::Float32));Sourcepub fn set_name(&mut self, name: PlSmallStr)
pub fn set_name(&mut self, name: PlSmallStr)
Sets the Field name.
§Example
let mut f = Field::new("Atomic number".into(), DataType::UInt32);
f.set_name("Proton".into());
assert_eq!(f, Field::new("Proton".into(), DataType::UInt32));Sourcepub fn with_name(self, name: PlSmallStr) -> Field
pub fn with_name(self, name: PlSmallStr) -> Field
Returns this Field, renamed.
Sourcepub fn to_arrow(&self, compat_level: CompatLevel) -> Field
pub fn to_arrow(&self, compat_level: CompatLevel) -> Field
Converts the Field to an arrow::datatypes::Field.
§Example
let f = Field::new("Value".into(), DataType::Int64);
let af = arrow::datatypes::Field::new("Value".into(), arrow::datatypes::ArrowDataType::Int64, true);
assert_eq!(f.to_arrow(CompatLevel::newest()), af);pub fn to_physical(&self) -> Field
Trait Implementations§
impl Eq for Field
impl StructuralPartialEq for Field
Auto Trait Implementations§
impl Freeze for Field
impl RefUnwindSafe for Field
impl Send for Field
impl Sync for Field
impl Unpin for Field
impl UnsafeUnpin for Field
impl UnwindSafe for Field
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more