MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / try_get

Method try_get

src/database/proxy.rs:164–186  ·  view source on GitHub ↗

Get a value from the [ProxyRow]

(&self, index: I)

Source from the content-addressed store, hash-verified

162impl ProxyRow {
163 /// Get a value from the [ProxyRow]
164 pub fn try_get<T, I: crate::ColIdx>(&self, index: I) -> Result<T, DbErr>
165 where
166 T: ValueType,
167 {
168 if let Some(index) = index.as_str() {
169 T::try_from(
170 self.values
171 .get(index)
172 .ok_or_else(|| query_err(format!("No column for ColIdx {index:?}")))?
173 .clone(),
174 )
175 .map_err(type_err)
176 } else if let Some(index) = index.as_usize() {
177 let (_, value) = self
178 .values
179 .iter()
180 .nth(*index)
181 .ok_or_else(|| query_err(format!("Column at index {index} not found")))?;
182 T::try_from(value.clone()).map_err(type_err)
183 } else {
184 unreachable!("Missing ColIdx implementation for ProxyRow");
185 }
186 }
187
188 /// An iterator over the keys and values of a proxy row
189 pub fn into_column_value_tuples(self) -> impl Iterator<Item = (String, Value)> {

Callers

nothing calls this directly

Calls 4

query_errFunction · 0.85
as_usizeMethod · 0.80
as_strMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected