/* * Copyright 2024 The Dragonfly Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ use dragonfly_client_backend::{Backend, Body, GetRequest, GetResponse, HeadRequest, HeadResponse}; use dragonfly_client_core::{Error, Result}; // Hdfs is a struct that implements the Backend trait struct Hdfs; // Hdfs implements the Backend trait impl Hdfs { pub fn new() -> Self { Self {} } } // Implement the Backend trait for Hdfs. #[tonic::async_trait] impl Backend for Hdfs { // scheme returns the scheme of the backend. fn scheme(&self) -> String { "hdfs".to_string() } // head is an async function that takes a HeadRequest and returns a HeadResponse. async fn head(&self, request: HeadRequest) -> Result { println!("HDFS head url: {}", request.url); Err(Error::Unimplemented) } // get is an async function that takes a GetRequest and returns a GetResponse. async fn get(&self, request: GetRequest) -> Result> { println!("HDFS get url: {}", request.url); Err(Error::Unimplemented) } } // register_plugin is a function that returns a Box. // This function is used to register the HDFS plugin to the Backend. #[no_mangle] pub fn register_plugin() -> Box { Box::new(Hdfs::new()) }