blob: 69b9e4c579d0f853b29c2d3f8bc37b2077d26b2f [file] [log] [blame]
// Copyright 2017 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "lib/svc/cpp/services.h"
#include <lib/fdio/directory.h>
#include <lib/fdio/fd.h>
#include <lib/fdio/fdio.h>
#include "src/lib/fxl/logging.h"
namespace component {
void ConnectToService(const zx::channel& directory, zx::channel request,
const std::string& service_path) {
fdio_service_connect_at(directory.get(), service_path.c_str(), request.release());
}
Services::Services() = default;
Services::~Services() = default;
Services::Services(Services&& other) : directory_(std::move(other.directory_)) {}
Services& Services::operator=(Services&& other) {
directory_ = std::move(other.directory_);
return *this;
}
zx::channel Services::NewRequest() {
zx::channel request;
FX_CHECK(zx::channel::create(0, &request, &directory_) == ZX_OK);
return request;
}
void Services::Bind(zx::channel directory) { directory_ = std::move(directory); }
} // namespace component