pub trait Resource: Debug + DeserializeOwned + Send + Serialize + Sync + 'static {
// Required methods
fn id_prefix() -> &'static str;
fn create_path() -> &'static str;
fn common(&self) -> &ResourceCommon;
fn id(&self) -> &Id<Self>;
fn status(&self) -> &dyn Status;
}
Expand description
A shared interface to all BigML resource types.
Implementing Resource
(internal only)
Normally you want to implement this using #[derive(Resource)]
, which will
look something like:
#[derive(Clone, Debug, Deserialize, Resource, Serialize, Updatable)]
#[api_name = "exampleresource"]
#[non_exhaustive]
pub struct ExampleResource {
/// Common resource information. These fields will be serialized at the
/// top-level of this structure by `serde`.
#[serde(flatten)]
#[updatable(flatten)]
pub common: ResourceCommon,
/// The ID of this resource.
pub resource: Id<ExampleResource>,
/// The status of this resource. (Must be a type which implements
/// `Status`, normally `GenericStatus` for most resources, except those
/// with extended status data.)
pub status: GenericStatus,
// Resource-specific fields here.
}
Required Methods§
sourcefn create_path() -> &'static str
fn create_path() -> &'static str
The URL path used to create a new resource of this type.
sourcefn common(&self) -> &ResourceCommon
fn common(&self) -> &ResourceCommon
Fields shared between all resource types. These are “flattened” into the top-level of the JSON version of this resource.