Struct thumbor::endpoint::Endpoint

source ·
pub struct Endpoint { /* private fields */ }
Expand description

An endpoint is a representation of a Thumbor image URL.

§Usage

EndpointBuilder is used to create an Endpoint instance.

You can then use the Endpoint::to_url method to generate the URL, or the Endpoint::to_path method to get the path (without the server origin).

The format of the image URI depends heavily on the image loader you are using. Thumbor comes pre-packaged with an HTTP loader and a Filesystem loader.

  • If you use the HTTP loader, the URI corresponds to the image complete URI.
  • If you use the Filesystem loader, the URI corresponds to the path of the image from the images root.

Implementations§

source§

impl Endpoint

source

pub fn to_path(&self, image_uri: &str) -> String

use thumbor::Server;

let server = Server::new_unsafe("http://localhost:8888");
let endpoint = server.endpoint_builder().build();
let path = endpoint.to_path("path/to/my/image.jpg");

assert_eq!(path, "/unsafe/path/to/my/image.jpg");
source

pub fn to_url(&self, image_uri: &str) -> String

use thumbor::Server;

let server = Server::new_unsafe("http://localhost:8888");
let endpoint = server.endpoint_builder().build();
let path = endpoint.to_url("path/to/my/image.jpg");

assert_eq!(path, "http://localhost:8888/unsafe/path/to/my/image.jpg");
source§

impl Endpoint

source

pub fn with_server(server: Server) -> EndpointBuilder

Create an instance of Endpoint using the builder syntax

Trait Implementations§

source§

impl Default for Endpoint

source§

fn default() -> Endpoint

Returns the “default value” for a type. 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> 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> Same for T

source§

type Output = T

Should always be Self
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.