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§
Source§impl<'de> Deserialize<'de> for Field
impl<'de> Deserialize<'de> for Field
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Field, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Field, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for Field
impl Serialize for Field
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
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 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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