As the docblock says, the id, name, and alias options are mutually exclusive.
|
/// At most one of `id`, `name`, or `alias` may be provided. |
|
pub async fn open( |
|
id: Option<String>, |
|
name: Option<String>, |
|
alias: Option<String>, |
Rust has sum types (called enums) that might help enforce this on the type level.
enum Identifier {
Id(String),
Name(String),
Alias(String),
}
fn open(id: Identifier) {
match id {
Identifier::Id(s) => /// open with id
Identifier::Name(s) => /// open with name
Identifier::Alias(s) => /// open with alias
}
}
open(Identifier::Alias('abcd'.to_string()))
The default storage access can be either implemented with a new explicit enum member (Identifier::Default), or id: Option<Identifier> (with the None variant opening the default storage).
As the docblock says, the
id,name, andaliasoptions are mutually exclusive.crawlee-storage/crawlee-storage/src/dataset.rs
Lines 44 to 48 in 4302d34
Rust has sum types (called enums) that might help enforce this on the type level.
The default storage access can be either implemented with a new explicit enum member (
Identifier::Default), orid: Option<Identifier>(with theNonevariant opening the default storage).