| 59 | |
| 60 | |
| 61 | pub async fn with_vecstore<'a>(mut self, opts: Options<'a>) -> Result<Schema, SchemaError> { |
| 62 | |
| 63 | if self.names.contains(opts.storage_name) { |
| 64 | return Err(SchemaError::DatastoreAlreadyExist(opts.storage_name.to_owned())) |
| 65 | } |
| 66 | |
| 67 | if let Some(_) = self.datastores.get::<VecStorage>() { |
| 68 | return Err(SchemaError::DatastoreAlreadyExist(opts.storage_name.to_owned())) |
| 69 | } |
| 70 | |
| 71 | match VecStorage::open(opts).await { |
| 72 | Err(e) => Err(SchemaError::Err(e)), |
| 73 | Ok(ds) => { |
| 74 | self.datastores.insert(ds); |
| 75 | Ok(self) |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | } |
| 80 | |
| 81 | |
| 82 | |