RelLink

Struct RelLink 

Source
pub struct RelLink { /* private fields */ }

Implementations§

Source

pub fn new(rel: &str, href: &str, method: HttpMethod) -> Self

Constructs a new RelLink

use hateoas::{HttpMethod, RelLink};

let rel = RelLink::new( "somewhere_obj","/somewhere/", HttpMethod::Get);
let validate = ("somewhere_obj", "/somewhere/", HttpMethod::Get).into();

assert_eq!(rel, validate);
Source

pub fn href(&self) -> &str

§Getter for href
use hateoas::{HttpMethod, RelLink};

let rel = RelLink::new( "somewhere_obj","/somewhere/", HttpMethod::Get);

assert_eq!(rel.href(), "/somewhere/");
Source

pub fn href_mut(&mut self) -> &mut String

§Getter/Setter for href
use hateoas::{HttpMethod, RelLink};

let mut rel = RelLink::new( "somewhere_obj","/somewhere/", HttpMethod::Get);

*(rel.href_mut()) = "/somewhere_else/".to_string();

assert_eq!(rel.href(), "/somewhere_else/");
Source

pub fn rel(&self) -> &str

§Getter for rel
use hateoas::{HttpMethod, RelLink};

let mut rel = RelLink::new( "somewhere_obj","/somewhere/", HttpMethod::Get);
   ///
assert_eq!(rel.rel(), "somewhere_obj");
Source

pub fn rel_mut(&mut self) -> &mut String

§Getter/Setter for rel
use hateoas::{HttpMethod, RelLink};

let mut rel = RelLink::new( "somewhere_obj","/somewhere/", HttpMethod::Get);

*(rel.rel_mut()) =  "somewhere_obj_2".to_string();

assert_eq!(rel.rel(),  "somewhere_obj_2");
Source

pub fn method(&self) -> &HttpMethod

§Getter for method
use hateoas::{HttpMethod, RelLink};

let mut rel = RelLink::new( "somewhere_obj","/somewhere/", HttpMethod::Get);    ///

assert_eq!(rel.method(), &HttpMethod::Get);
Source

pub fn method_mut(&mut self) -> &mut HttpMethod

§Getter/Setter for rel
use hateoas::{HttpMethod, RelLink};

let mut rel = RelLink::new( "somewhere_obj","/somewhere/", HttpMethod::Get);

*(rel.method_mut()) = HttpMethod::Connect;

assert_eq!(rel.method(),  &HttpMethod::Connect);
Source

pub fn GET(rel: &str, href: &str) -> RelLink

The GET method requests a representation of the specified resource. Requests using GET should only retrieve data.

use hateoas::{HttpMethod, RelLink};
 
let rel = RelLink::GET("object", "/path/to/objects");
 
assert_eq!(rel, RelLink::new("object", "/path/to/objects", HttpMethod::Get));
Source

pub fn HEAD(rel: &str, href: &str) -> RelLink

The HEAD method asks for a response identical to a GET request, but without the response body.

use hateoas::{HttpMethod, RelLink};
 
let rel = RelLink::HEAD("object", "/path/to/objects");
 
assert_eq!(rel, RelLink::new("object", "/path/to/objects", HttpMethod::Head));
Source

pub fn POST(rel: &str, href: &str) -> RelLink

The POST method submits an entity to the specified resource, often causing a change in state or side effects on the server.

use hateoas::{HttpMethod, RelLink};
 
let rel = RelLink::POST("object", "/path/to/objects");
 
assert_eq!(rel, RelLink::new("object", "/path/to/objects", HttpMethod::Post));
Source

pub fn PUT(rel: &str, href: &str) -> RelLink

The PUT method replaces all current representations of the target resource with the request payload.

use hateoas::{HttpMethod, RelLink};
 
let rel = RelLink::PUT("object", "/path/to/objects");
 
assert_eq!(rel, RelLink::new("object", "/path/to/objects", HttpMethod::Put));
Source

pub fn DELETE(rel: &str, href: &str) -> RelLink

The DELETE method deletes the specified resource.

use hateoas::{HttpMethod, RelLink};
 
let rel = RelLink::DELETE("object", "/path/to/objects");
 
assert_eq!(rel, RelLink::new("object", "/path/to/objects", HttpMethod::Delete));
Source

pub fn CONNECT(rel: &str, href: &str) -> RelLink

The CONNECT method establishes a tunnel to the server identified by the target resource.

use hateoas::{HttpMethod, RelLink};
 
let rel = RelLink::CONNECT("object", "/path/to/objects");
 
assert_eq!(rel, RelLink::new("object", "/path/to/objects", HttpMethod::Connect));
Source

pub fn OPTIONS(rel: &str, href: &str) -> RelLink

The OPTIONS method describes the communication options for the target resource.

use hateoas::{HttpMethod, RelLink};
 
let rel = RelLink::OPTIONS("object", "/path/to/objects");
 
assert_eq!(rel, RelLink::new("object", "/path/to/objects", HttpMethod::Options));
Source

pub fn TRACE(rel: &str, href: &str) -> RelLink

The TRACE method performs a message loop-back test along the path to the target resource.

use hateoas::{HttpMethod, RelLink};
 
let rel = RelLink::TRACE("object", "/path/to/objects");
 
assert_eq!(rel, RelLink::new("object", "/path/to/objects", HttpMethod::Trace));
Source

pub fn PATCH(rel: &str, href: &str) -> RelLink

The PATCH method applies partial modifications to a resource.

use hateoas::{HttpMethod, RelLink};
 
let rel = RelLink::PATCH("object", "/path/to/objects");
 
assert_eq!(rel, RelLink::new("object", "/path/to/objects", HttpMethod::Patch));

Trait Implementations§

Source§

fn clone(&self) -> RelLink

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

fn from(r: (&str, &str, HttpMethod)) -> Self

Converts to this type from the input type.
Source§

fn from(r: (String, String, HttpMethod)) -> Self

Converts to this type from the input type.
Source§

fn eq(&self, other: &RelLink) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,