ipfs-chromium
Public Types | Public Member Functions | Protected Attributes | List of all members
ipfs::Client Class Reference

Interface that provides functionality from whatever environment you're using this library in. More...

#include <library/include/ipfs_client/client.h>

Inheritance diagram for ipfs::Client:
Inheritance graph
[legend]
Collaboration diagram for ipfs::Client:
Collaboration graph
[legend]

Public Types

using SigningKeyType = ::ipfs::crypto::SigningKeyType
 
using MimeTypeDeduction = std::function< std::string(std::string, std::string_view, std::string const &)>
 
using UrlUnescaping = std::function< std::string(std::string_view)>
 
using DnslinkFallbackSwitch = std::function< bool()>
 
using ByteView = ::ipfs::ByteView
 

Public Member Functions

std::shared_ptr< Partitionpartition (std::string key)
 
ctx::HttpApihttp ()
 
ctx::DnsTxtLookupdns_txt ()
 
ctx::GatewayConfiggw_cfg ()
 
ctx::JsonParserjson ()
 
ctx::CborParsercbor ()
 
std::shared_ptr< gw::Requestorrequestor ()
 
Clientwith (std::unique_ptr< ctx::HttpApi >)
 
Clientwith (std::unique_ptr< ctx::DnsTxtLookup >)
 
Clientwith (std::unique_ptr< ctx::GatewayConfig >)
 
Clientwith (std::unique_ptr< ctx::JsonParser >)
 
Clientwith (std::unique_ptr< ctx::CborParser >)
 
Clientwith (std::shared_ptr< gw::Requestor >)
 
Clientwith (SigningKeyType, std::unique_ptr< crypto::SignatureVerifier >)
 
Clientwith (MimeTypeDeduction)
 
Clientwith (UrlUnescaping)
 
Clientwith (DnslinkFallbackSwitch)
 
std::string MimeType (std::string extension, std::string_view content, std::string const &url)
 Determine a mime type for a given file. More...
 
std::string UnescapeUrlComponent (std::string_view url_comp)
 Remove URL escaping, e.g. %20. More...
 
bool VerifyKeySignature (SigningKeyType, ByteView signature, ByteView data, ByteView key_bytes) const
 
std::optional< std::vector< Byte > > Hash (HashType, ByteView data)
 
bool DnslinkFallback () const
 

Protected Attributes

std::unordered_map< HashType, std::unique_ptr< crypto::Hasher > > hashers_
 
std::unordered_map< SigningKeyType, std::unique_ptr< crypto::SignatureVerifier > > verifiers_
 
std::unique_ptr< ctx::HttpApihttp_api_
 
std::unique_ptr< ctx::DnsTxtLookupdns_txt_
 
std::unique_ptr< ctx::GatewayConfiggateway_config_
 
std::unique_ptr< ctx::JsonParserjson_parser_
 
std::unique_ptr< ctx::CborParsercbor_parser_
 
MimeTypeDeduction deduce_mime_type_
 
UrlUnescaping unescape_
 
std::shared_ptr< gw::Requestorrtor_
 
std::unordered_map< std::string, std::shared_ptr< Partition > > partitions_
 
DnslinkFallbackSwitch dns_fb_
 

Detailed Description

Interface that provides functionality from whatever environment you're using this library in.

Note
A user of this library must implement this, but will probably do so only once.

Member Function Documentation

◆ MimeType()

std::string ipfs::Client::MimeType ( std::string  extension,
std::string_view  content,
std::string const &  url 
)

Determine a mime type for a given file.

Parameters
extension- "File extension" not including ., e.g. "html"
content- The content of the resource or a large prefix thereof
url- A URL it was fetched from (of any sort, ipfs:// is fine)

◆ UnescapeUrlComponent()

std::string ipfs::Client::UnescapeUrlComponent ( std::string_view  url_comp)

Remove URL escaping, e.g. %20.

Parameters
url_comp- a single component of the URL, e.g. a element of the path not including /
Returns
The unescaped string

The documentation for this class was generated from the following file: