Trait austenite::resource::Resource
[-]
[+]
[src]
pub trait Resource { fn service_available(&self, _: &Request, _: &mut Response) -> bool { ... } fn known_method(&self, req: &Request, _: &mut Response) -> bool { ... } fn uri_too_long(&self, _: &Request, _: &mut Response) -> bool { ... } fn method_allowed(&self, req: &Request, _: &mut Response) -> bool { ... } fn malformed(&self, _: &Request, _: &mut Response) -> bool { ... } fn authorized(&self, _: &Request, _: &mut Response) -> bool { ... } fn allowed(&self, _: &Request, _: &mut Response) -> bool { ... } fn valid_content_header(&self, _: &Request, _: &mut Response) -> bool { ... } fn known_content_type(&self, _: &Request, _: &mut Response) -> bool { ... } fn valid_entity_length(&self, _: &Request, _: &mut Response) -> bool { ... } fn exists(&self, _: &Request, _: &mut Response) -> bool { ... } fn existed(&self, _: &Request, _: &mut Response) -> bool { ... } fn respond_with_entity(&self, _: &Request, _: &mut Response) -> bool { ... } fn new(&self, _: &Request, _: &mut Response) -> bool { ... } fn post_redirect(&self, _: &Request, _: &mut Response) -> bool { ... } fn put_to_different_url(&self, _: &Request, _: &mut Response) -> bool { ... } fn multiple_representations(&self, _: &Request, _: &mut Response) -> bool { ... } fn conflict(&self, _: &Request, _: &mut Response) -> bool { ... } fn can_post_to_missing(&self, _: &Request, _: &mut Response) -> bool { ... } fn can_post_to_gone(&self, _: &Request, _: &mut Response) -> bool { ... } fn can_put_to_missing(&self, _: &Request, _: &mut Response) -> bool { ... } fn moved_permanently(&self, _: &Request, _: &mut Response) -> bool { ... } fn moved_temporarily(&self, _: &Request, _: &mut Response) -> bool { ... } fn delete_enacted(&self, _: &Request, _: &mut Response) -> bool { ... } fn processable(&self, _: &Request, _: &mut Response) -> bool { ... } fn etag(&self, _: &Request, _: &mut Response) -> Option<Etag> { ... } fn last_modified(&self, _: &Request, _: &Response) -> Option<Tm> { ... } fn delete(&self, _: &Request, _: &mut Response) -> ResourceResult { ... } fn patch(&self, _: &Request, _: &mut Response) -> ResourceResult { ... } fn post(&self, _: &Request, _: &mut Response) -> ResourceResult { ... } fn put(&self, _: &Request, _: &mut Response) -> ResourceResult { ... } fn available_languages(&self, _: &Request, _: &mut Response) -> Vec<String> { ... } fn available_charsets(&self, _: &Request, _: &mut Response) -> Vec<String> { ... } fn available_encodings(&self, _: &Request, _: &mut Response) -> Vec<Encoding> { ... } fn available_content_types(&self, _: &Request, _: &mut Response) -> Vec<Mime> { ... } fn accept_exists(&self, req: &Request, resp: &mut Response) -> bool { ... } fn media_type_available(&self, req: &Request, resp: &mut Response) -> bool { ... } fn language_available(&self, req: &Request, resp: &mut Response) -> bool { ... } fn charset_available(&self, req: &Request, resp: &mut Response) -> bool { ... } fn encoding_available(&self, req: &Request, resp: &mut Response) -> bool { ... } fn if_match(&self, req: &Request, resp: &mut Response) -> bool { ... } fn if_none_match(&self, req: &Request, resp: &mut Response) -> bool { ... } fn if_match_star(&self, req: &Request, _: &mut Response) -> bool { ... } fn if_none_match_star(&self, req: &Request, _: &mut Response) -> bool { ... } fn unmodified_since(&self, req: &Request, resp: &mut Response) -> bool { ... } fn modified_since(&self, req: &Request, resp: &mut Response) -> bool { ... } fn if_match_star_exists_for_missing(&self, req: &Request, _: &mut Response) -> bool { ... } fn service_available_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn known_method_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn uri_too_long_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn method_allowed_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn malformed_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn authorized_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn allowed_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn valid_content_header_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn known_content_type_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn valid_entity_length_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn is_options_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn accept_exists_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn media_type_available_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn accept_language_exists_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn language_available_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn accept_charset_exists_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn charset_available_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn accept_encoding_exists_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn encoding_available_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn processable_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn exists_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn if_match_exists_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn if_match_star_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn if_match_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn if_unmodified_since_exists_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn if_unmodified_since_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn if_none_match_exists_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn if_none_match_star_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn if_none_match_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn none_match_status_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn if_modified_since_exists_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn if_modified_since_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn method_delete_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn method_patch_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn post_to_existing_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn put_to_existing_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn if_match_star_exists_for_missing_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn method_put_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn put_to_different_url_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn can_put_to_missing_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn conflict_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn existed_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn moved_permanently_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn moved_temporarily_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn post_to_gone_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn can_post_to_gone_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn post_to_missing_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn can_post_to_missing_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn post_redirect_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn new_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn respond_with_entity_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn multiple_representations_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult { ... } fn handle_service_unavailable(&self, _: &Request, resp: &mut Response) -> ResourceResult { ... } fn handle_unknown_method(&self, _: &Request, resp: &mut Response) -> ResourceResult { ... } fn handle_uri_too_long(&self, _: &Request, resp: &mut Response) -> ResourceResult { ... } fn handle_method_not_allowed(&self, _: &Request, resp: &mut Response) -> ResourceResult { ... } fn handle_malformed(&self, _: &Request, resp: &mut Response) -> ResourceResult { ... } fn handle_unauthorized(&self, _: &Request, resp: &mut Response) -> ResourceResult { ... } fn handle_forbidden(&self, _: &Request, resp: &mut Response) -> ResourceResult { ... } fn handle_not_implemented(&self, _: &Request, resp: &mut Response) -> ResourceResult { ... } fn handle_unsupported_media_type(&self, _: &Request, resp: &mut Response) -> ResourceResult { ... } fn handle_request_entity_too_large(&self, _: &Request, resp: &mut Response) -> ResourceResult { ... } fn handle_not_acceptable(&self, _: &Request, resp: &mut Response) -> ResourceResult { ... } fn handle_unprocessable_entity(&self, _: &Request, resp: &mut Response) -> ResourceResult { ... } fn handle_conflict(&self, _: &Request, resp: &mut Response) -> ResourceResult { ... } fn handle_see_other(&self, _: &Request, resp: &mut Response) -> ResourceResult { ... } fn handle_created(&self, _: &Request, resp: &mut Response) -> ResourceResult { ... } fn handle_precondition_failed(&self, _: &Request, resp: &mut Response) -> ResourceResult { ... } fn handle_not_modified(&self, _: &Request, resp: &mut Response) -> ResourceResult { ... } fn handle_moved_permanently(&self, _: &Request, resp: &mut Response) -> ResourceResult { ... } fn handle_moved_temporarily(&self, _: &Request, resp: &mut Response) -> ResourceResult { ... } fn handle_gone(&self, _: &Request, resp: &mut Response) -> ResourceResult { ... } fn handle_not_found(&self, _: &Request, resp: &mut Response) -> ResourceResult { ... } fn handle_no_content(&self, _: &Request, resp: &mut Response) -> ResourceResult { ... } fn handle_multiple_representations(&self, _: &Request, resp: &mut Response) -> ResourceResult { ... } fn handle_ok(&self, _: &Request, resp: &mut Response) -> ResourceResult { ... } fn handle_options(&self, _: &Request, resp: &mut Response) -> ResourceResult { ... } }
Main trait for an HTTP resource.
Implement this trait's optional functions to control how the HTTP request is handled.
Provided Methods
fn service_available(&self, _: &Request, _: &mut Response) -> bool
Override to control service availability. If this returns false, then a 503 ServiceUnavailable reply will result. Defaults to true.
fn known_method(&self, req: &Request, _: &mut Response) -> bool
Override to control known HTTP verbs. If this returns false, then a 501 NotImplemented reply will result. Defaults to true.
fn uri_too_long(&self, _: &Request, _: &mut Response) -> bool
Override to limit uri length. If this returns true, then a 414 RequestUriTooLong reply will result. Defaults to false.
fn method_allowed(&self, req: &Request, _: &mut Response) -> bool
Override to control valid HTTP verbs for the request. If this returns false, then a 405 MethodNotAllowed reply will result. Defaults to alowing GET and HEAD.
fn malformed(&self, _: &Request, _: &mut Response) -> bool
Override to control request validity. If this returns false, then a 405 MethodNotAllowed reply will result. Defaults to alowing GET and HEAD.
fn authorized(&self, _: &Request, _: &mut Response) -> bool
Override to control request authentication. If this returns false, then a 401 Unauthorized reply will result. Defaults to true.
fn allowed(&self, _: &Request, _: &mut Response) -> bool
Override to control request authorisation. If this returns false, then a 403 Forbidden reply will result. Defaults to true.
fn valid_content_header(&self, _: &Request, _: &mut Response) -> bool
Override to control content header validity. If this returns false, then a 501 NotImplemented reply will result. Defaults to true.
fn known_content_type(&self, _: &Request, _: &mut Response) -> bool
Override to control content type validity. If this returns false, then a 415 UnsupportedMediaType reply will result. Defaults to true.
fn valid_entity_length(&self, _: &Request, _: &mut Response) -> bool
Override to control content length validity. If this returns false, then a 413 RequestEntityTooLarge reply will result. Defaults to true.
fn exists(&self, _: &Request, _: &mut Response) -> bool
Override to control whether an entity exists. If this returns false, then the entity is deemed not too exist. This effects the handling of POST, PUT, and DELETE verbs. Defaults to true.
fn existed(&self, _: &Request, _: &mut Response) -> bool
Override to control whether an entity once existed. If this returns false, then the entity is deemed not to have existed. This effects the handling of GET, POST, and PUT verbs. Defaults to true.
fn respond_with_entity(&self, _: &Request, _: &mut Response) -> bool
Control whether an entity is returned. If false, returns 205 NoContent. Defaults to false.
fn new(&self, _: &Request, _: &mut Response) -> bool
Indicates whether an entity was successfully created for the request. Defaults to true.
fn post_redirect(&self, _: &Request, _: &mut Response) -> bool
Controls whether to redirect after a POST request. Defaults to false.
fn put_to_different_url(&self, _: &Request, _: &mut Response) -> bool
Indicates the PUT request should be made to a different URL. Defaults to false.
fn multiple_representations(&self, _: &Request, _: &mut Response) -> bool
Controls whether to return a 300 MultipleChoices response. Defaults to false.
fn conflict(&self, _: &Request, _: &mut Response) -> bool
Indicates the PUT request has resulted in a conflict. If this returns true, it will cause a 409 Conflict response. Defaults to false.
fn can_post_to_missing(&self, _: &Request, _: &mut Response) -> bool
Controls whether a POST to a non existing entity is handled. When false, causes a 410 Gone response. Defaults to true.
fn can_post_to_gone(&self, _: &Request, _: &mut Response) -> bool
Controls whether a POST to a deleted entity is handled. When false, causes a 410 Gone response. Defaults to false.
fn can_put_to_missing(&self, _: &Request, _: &mut Response) -> bool
Controls whether a PUT to a non-existing entity is handled. When false, causes a 501 NotImplemented response. Defaults to true.
fn moved_permanently(&self, _: &Request, _: &mut Response) -> bool
Indicates whether a resource was moved permanently. Defaults to false.
fn moved_temporarily(&self, _: &Request, _: &mut Response) -> bool
Indicates whether a resource was moved temporarily. Defaults to false.
fn delete_enacted(&self, _: &Request, _: &mut Response) -> bool
Indicates whether a delete request was processed. Defaults to true.
fn processable(&self, _: &Request, _: &mut Response) -> bool
Indicates whether an entity is processable. Returns 422 UnprocessableEntity when false. Defaults to true.
fn etag(&self, _: &Request, _: &mut Response) -> Option<Etag>
Return an optional ETag for the entity
fn last_modified(&self, _: &Request, _: &Response) -> Option<Tm>
Return an optional last modified time for the entity
fn delete(&self, _: &Request, _: &mut Response) -> ResourceResult
Execute a DELETE request. Will assert! by default.
fn patch(&self, _: &Request, _: &mut Response) -> ResourceResult
Execute a PATCH request. Will assert! by default.
fn post(&self, _: &Request, _: &mut Response) -> ResourceResult
Execute a POST request. Will assert! by default.
fn put(&self, _: &Request, _: &mut Response) -> ResourceResult
Execute a PUT request. Will assert! by default.
fn available_languages(&self, _: &Request, _: &mut Response) -> Vec<String>
Return a vector of available languages.
fn available_charsets(&self, _: &Request, _: &mut Response) -> Vec<String>
Return a vector of available charsets.
fn available_encodings(&self, _: &Request, _: &mut Response) -> Vec<Encoding>
Return a vector of available encodings.
fn available_content_types(&self, _: &Request, _: &mut Response) -> Vec<Mime>
Return a vector of available content types.
fn accept_exists(&self, req: &Request, resp: &mut Response) -> bool
base logic
fn media_type_available(&self, req: &Request, resp: &mut Response) -> bool
fn language_available(&self, req: &Request, resp: &mut Response) -> bool
fn charset_available(&self, req: &Request, resp: &mut Response) -> bool
fn encoding_available(&self, req: &Request, resp: &mut Response) -> bool
fn if_match(&self, req: &Request, resp: &mut Response) -> bool
fn if_none_match(&self, req: &Request, resp: &mut Response) -> bool
fn if_match_star(&self, req: &Request, _: &mut Response) -> bool
fn if_none_match_star(&self, req: &Request, _: &mut Response) -> bool
fn unmodified_since(&self, req: &Request, resp: &mut Response) -> bool
fn modified_since(&self, req: &Request, resp: &mut Response) -> bool
fn if_match_star_exists_for_missing(&self, req: &Request, _: &mut Response) -> bool
fn service_available_decision(&self, req: &Request, resp: &mut Response) -> ResourceResult
logic functions