Trait bigml::resource::Resource

source ·
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§

source

fn id_prefix() -> &'static str

The prefix used for all IDs of this type.

source

fn create_path() -> &'static str

The URL path used to create a new resource of this type.

source

fn common(&self) -> &ResourceCommon

Fields shared between all resource types. These are “flattened” into the top-level of the JSON version of this resource.

source

fn id(&self) -> &Id<Self>

The ID of this resource.

source

fn status(&self) -> &dyn Status

The status code for this resource.

TODO: Does this need to go in a separate trait in order to maintain trait object support?

Implementors§