pub trait ObjectSetMethods: Copy + Sized {
type Each: Sized;
type Field: Sized;
// Required methods
fn resolve_option(
self,
found: Option<Self::Each>,
) -> Result<Self::Field, EP>;
fn debug_core(self) -> &'static str;
// Provided methods
fn object_set_debug(self) -> impl Debug { ... }
fn check_label(self, label: &str) -> Result<(), EP>
where Self::Each: ItemObjectParseable { ... }
fn check_object_parseable(self)
where Self::Each: ItemObjectParseable { ... }
}Expand description
Method for handling some multiplicity of Objects
For use by macros.
See the module-level docs, and
Field type in ItemValueParseable.
§Example
The code in the (derive) macro output is roughly like this:
use tor_netdoc::parse2::multiplicity::{MultiplicitySelector, ObjectSetMethods as _};
use tor_netdoc::parse2::{ItemStream, ParseInput};
let doc = "intro-item\n-----BEGIN OBJECT-----\naGVsbG8=\n-----END OBJECT-----\n";
let input = ParseInput::new(doc, "<literal>");
let mut items = ItemStream::new(&input).unwrap();
let mut item = items.next().unwrap().unwrap();
let selector = MultiplicitySelector::<Option<String>>::default();
let obj = item.object().map(|obj| {
let data = obj.decode_data().unwrap();
String::from_utf8(data)
}).transpose().unwrap();
let obj = selector.resolve_option(obj).unwrap();
assert_eq!(obj, Some("hello".to_owned()));Required Associated Types§
Required Methods§
Sourcefn resolve_option(self, found: Option<Self::Each>) -> Result<Self::Field, EP>
fn resolve_option(self, found: Option<Self::Each>) -> Result<Self::Field, EP>
Parse zero or more argument(s) into Self::Field.
Sourcefn debug_core(self) -> &'static str
fn debug_core(self) -> &'static str
Multiplicity representation for #[deftly(netdoc(debug))] output, core
Should generally be in a form like Option<_>.
See ItemSetMethods::debug_core and ObjectSetMethods::object_set_debug.
Provided Methods§
Sourcefn object_set_debug(self) -> impl Debug
fn object_set_debug(self) -> impl Debug
Multiplicity representation for #[deftly(netdoc(debug))] output
See ItemSetMethods::item_set_debug and ObjectSetMethods::debug_core.
Sourcefn check_label(self, label: &str) -> Result<(), EP>where
Self::Each: ItemObjectParseable,
fn check_label(self, label: &str) -> Result<(), EP>where
Self::Each: ItemObjectParseable,
If the contained type is ItemObjectParseable, call its check_label
Sourcefn check_object_parseable(self)where
Self::Each: ItemObjectParseable,
fn check_object_parseable(self)where
Self::Each: ItemObjectParseable,
Check that the contained type can be parsed as an object
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.