pub trait Shape {
// Required methods
fn id(&self) -> ShapeId;
fn key(&self, name: &str) -> Option<Key>;
}Expand description
The names a view answers.
use web_net::{Key, Shape, ShapeId};
struct PostShape;
impl Shape for PostShape {
fn id(&self) -> ShapeId { ShapeId(1) }
fn key(&self, name: &str) -> Option<Key> {
match name { "title" => Some(Key(0)), "body" => Some(Key(1)), _ => None }
}
}
assert_eq!(PostShape.key("body"), Some(Key(1)));
assert_eq!(PostShape.key("author"), None);Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".